2016-04-05 19 views
1

我想獲得MEF獲得作用域在測試庫的.Net 4.7.1工作,我得到三個錯誤與下面的命令無法從「System.Reflection.Assembly轉換 - MEF作用域

var configuration = new ContainerConfiguration() 
       .WithAssembly(typeof(MefScope).Assembly, conventions); 

哪裏MefScope是類,其中上述線路發生(第32行)

我得到的錯誤是

Error 7 Argument 1: cannot convert from 'System.Reflection.Assembly 
[c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll]' to 
'System.Reflection.Assembly' D:\MyTest\___rc\PB\MyTest.Test\MefScope.cs 33 35 MyTest.Test 

Error 6 The best overloaded method match for 'System.Composition.Hosting.ContainerConfiguration.WithAssembly(System.Reflection.Assembly, System.Composition.Convention.AttributedModelProvider)' 
has some invalid arguments D:\MyTest\___rc\PB\MyTest.Test\MefScope.cs 33 21 MyTest.Test 

Error 5 The type 'System.Reflection.Assembly' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. D:\MyTest\___rc\PB\MyTest.Test\MefScope.cs 32 13 MyTest.Test 

我假設這是某種DLL不匹配,但我不知道在哪裏System.Reflection,版本= 4.0.0.0是。也許我一起錯過了這一點。

難道某種靈魂會指向正確的方向。我需要使用.Net 4.5.1。

回答

0

這似乎是在單個項目中發生的事情。當我創建一個新項目並添加相同的代碼(和引用)時,問題就消失了。

相關問題