microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
216 stars 83 forks source link

TypeLoadException with lack of details #126

Closed jzabroski closed 3 years ago

jzabroski commented 3 years ago

I got this mysterious error today, and there is not enough information to know how it occurred. It only happened once. Issue happened one other time since updating to Visual Studio 2019 16.9.4

$target = "testsetup";
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MsBuild.exe" build.targets /v:minimal /m /t:$target

Output:

Unhandled Exception: System.TypeLoadException: The signature is incorrect.
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main()
Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Here is also from the Windows Event Viewer log:

Event Source: .NET Runtime, EventID: 1026, Task Code: None, Date and Time: 4/29/2021 03:03:12 PM ET

Application: MsBuild.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(System.String)
   at Microsoft.Build.CommandLine.MSBuildApp.Main()

Event Source: Applicaiton Error, EventID: 1000, Task Code: (100), Date and Time: 4/29/2021 03:03:12 PM ET

Faulting application name: MsBuild.exe, version: 16.9.0.16703, time stamp: 0xda545832
Faulting module name: KERNELBASE.dll, version: 10.0.14393.4350, time stamp: 0x606eb12a
Exception code: 0xe0434352
Fault offset: 0x000dc602
Faulting process id: 0x3958
Faulting application start time: 0x01d73d2a4d045461
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MsBuild.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: bbfcaed5-3b54-4fab-90be-7a44a414f291
Faulting package full name: 
Faulting package-relative application ID: 
benvillalobos commented 3 years ago

Team Triage: MSBuild.exe doesn't use MSBuildLocator