You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to use MSBuildWorkspace in a .NET Core csproj targeting net46, I get assembly load exceptions.
Steps to reproduce
Create a component test project (.NET Core)
Change TargetFramework from netcoreapp1.1 to net46
Add Microsoft.CodeAnalysis version 2.0.0 to the unit test project
Create the MSBuildWorkspace in the test method using MSBuildWorkspace.Create();
Run the unit tests
Expected behavior
No error
Actual behavior
A System.Reflection.ReflectionTypeLoadException is thrown. The LoaderExceptions contains the following fusion log:
=== Zustandsinformationen vor Bindung ===
LOG: DisplayName = System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///c:/users/mark/documents/visual studio 2017/Projects/TestRoslyn20/TestRoslyn20Tests/bin/Debug/net46
LOG: Ursprünglicher PrivatePath = NULL
Aufruf von Assembly : System.Reflection.Metadata, Version=1.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: Diese Bindung startet im default-Load-Kontext.
LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Die Hostkonfigurationsdatei wird verwendet:
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet.
LOG: Die gleiche Bindung ist bereits aufgetreten und hat den Fehler hr = 0x80131040 verursacht.
This log shows that System.Reflection.Metadata version 1.4.1.0 tried to load System.Collections.Immutable version 1.2.0.0, but I cannot downgrade to this version, because Roslyn requires 1.2.1 (NuGet package version 1.3.1).
Stack trace:
bei System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
bei System.Reflection.RuntimeAssembly.get_DefinedTypes()
bei System.Composition.Hosting.ContainerConfiguration.<WithAssemblies>b__0(Assembly a)
bei System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
bei System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
bei System.Composition.Hosting.ContainerConfiguration.CreateContainer()
bei Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
bei Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices()
bei Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create()
bei TestRoslyn20Tests.UnitTest1.Test1() in c:\users\mark\documents\visual studio 2017\Projects\TestRoslyn20\TestRoslyn20Tests\UnitTest1.cs:Zeile 14.
Upgrading the package Microsoft.Composition doesn't work, because it complains with a FileLoadException that the assembly System.Composition.TypedParts version 1.0.27.0 couldn't be loaded.
This is the stack trace:
bei Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
bei Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices()
bei Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create()
bei TestRoslyn20Tests.UnitTest1.Test1() in c:\users\mark\documents\visual studio 2017\Projects\TestRoslyn20\TestRoslyn20Tests\UnitTest1.cs: Zeile14
Using an app.config for the test project doesn't work. The .dll.config gets copied to the output folder, but the binding redirect isn't picked up.
1) microsoft#613
2) microsoft#428
3) microsoft#391
4) microsoft#595
Fix:
Generate config file for test project targeting .NET Framework. This config file has have binding redirect which is needed at time of running tests.
* Issue:
1) #428
2) #595
Fix:
Generate config file for test project targeting .NET Framework. This config file has binding redirect which is needed at time of running tests.
Description
When I try to use MSBuildWorkspace in a .NET Core csproj targeting net46, I get assembly load exceptions.
Steps to reproduce
TargetFramework
fromnetcoreapp1.1
tonet46
Microsoft.CodeAnalysis
version 2.0.0 to the unit test projectMSBuildWorkspace
in the test method usingMSBuildWorkspace.Create();
Expected behavior
No error
Actual behavior
A
System.Reflection.ReflectionTypeLoadException
is thrown. TheLoaderExceptions
contains the following fusion log:This log shows that
System.Reflection.Metadata
version 1.4.1.0 tried to loadSystem.Collections.Immutable
version 1.2.0.0, but I cannot downgrade to this version, because Roslyn requires 1.2.1 (NuGet package version 1.3.1).Stack trace:
Upgrading the package
Microsoft.Composition
doesn't work, because it complains with aFileLoadException
that the assemblySystem.Composition.TypedParts
version 1.0.27.0 couldn't be loaded.This is the stack trace:
Using an app.config for the test project doesn't work. The
.dll.config
gets copied to the output folder, but the binding redirect isn't picked up.I think that the problem is two-fold:
Fun fact: Using a .NET Framework console application works without error.
Environment
Workaround
Use a .NET Framework unit test project and add the following lines in the
PropertyGroup
:The text was updated successfully, but these errors were encountered: