引用的程序会自动由Visual Studio取代程序、Visual、Studio

2023-09-06 15:32:46 作者:傲气一世

我有2个项目,便携式类库和常规单元测试项目。在便携式类库,我用的NuGet引用Microsoft.BCL便携包,它配备了2集( System.Threading.Tasks.dll System.Runtime.dll 这两个V1.5)。

I have 2 projects, a Portable class library and a regular unit test project. In the Portable class library, I use NuGet to reference the Microsoft.BCL Portability pack, which comes with 2 assemblies (System.Threading.Tasks.dll and System.Runtime.dll both v1.5).

然而,当我尝试引用这些相同的dll文件在我的单元测试项目(包括带的NuGet和手动浏览到该目录 \包\ Microsoft.Bcl.1.0.19 \ LIB \便携式net40 + SL4 + win8的+ wp71 ),Visual Studio会自动指向的refence在这里设下再夹中的dll文件:\程序文件(x86)\参考大会\微软\框架\ .NETFramework \ V4.5 \ ,这是4.5版本。

However, when I try to reference these same dlls in my unit test project (both with NuGet and manually browsing to the directory \packages\Microsoft.Bcl.1.0.19\lib\portable-net40+sl4+win8+wp71), visual studio automatically points the refence to the dlls in another folder located here C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\, which is of version 4.5.

现在的方法,我需要测试接受的CancellationToken 作为参数,并抛出编译错误:类型System.Threading.CancellationToken'是在未引用的程序集定义。您必须添加一个引用程序集System.Threading.Tasks,版本= 1.5.11.0,文化=中性公钥= b03f5f7f11d50a3a',因为它的V4.5库是什么引用,而不是1.5版。

Now a method I need to test accepts CancellationToken as a parameter and throws the compile error: The type 'System.Threading.CancellationToken' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because its v4.5 library is whats referenced and not v1.5.

我也不过是能写测试,不使用任何这些功能从V1.5 BCL库的方法。

I have however been able to write tests for methods that does not use any of those features from the v1.5 BCL library.

为什么视觉工作室取代我引用的库与随附的框架呢?我如何告诉Visual Studio中只使用那些我指着一个特定的目录?

Why is visual studio replacing my referenced library with the one that came with the framework? How do I tell visual studio to just use the ones I'm pointing to in a specific directory?

使用的Visual Studio 2012更新2。

Using Visual Studio 2012 Update 2.

推荐答案

这似乎是一个问题与Visual Studio更新2,因为它不与Visual Studio 2013年发生在我Visual Studio和较新版本中打开项目正确的组件被装。

This seemed like an issue with visual studio update 2 as this does not occur with visual studio 2013. I opened the project in the newer version of visual studio and the correct assemblies were loaded.

我不知道,如果一个插件是这个原因。

I'm not sure if a plugin was the cause of this.