NUnit程序集如何出现在VS的“添加引用"中对话? [英] How are NUnit assemblies appearing in VS "Add Reference" dialog?

查看:93
本文介绍了NUnit程序集如何出现在VS的“添加引用"中对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在安装NUnit之后,程序集(nunit.framework等)现在出现在References > Add Reference对话框中,但是它们不在%WINDIR%\Microsoft.NET\Framework\v2.0.50727目录中,并且程序集没有NUnit注册表项路径(i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramewokr\AssemblyFolder).

So after installing NUnit, the assemblies (nunit.framework, etc.) now appear in the References > Add Reference dialog, but they're not in the %WINDIR%\Microsoft.NET\Framework\v2.0.50727 dir and there is no NUnit registry entry for the Assembly Path (i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramewokr\AssemblyFolder).

NUnit安装目录的项目属性参考路径"中也没有自动创建条目.它们到底如何出现在添加对话框"中?!?!我认为上述方法是程序集可以出现在添加引用"中的唯一方法.

There's also no automatic entries created in the project properties Reference Paths for the NUnit install directory. How the heck are they appearing in the "Add Dialog"?!?! I thought the mentioned way were the only ways assemblies could appear in "Add Reference".

推荐答案

我在周末对此进行了更深入的研究.从我的

I dug deeper into this at the weekend. Reproduced verbatim from my blog:

因为Visual Studio不在GAC中查找引用,所以:

Because Visual Studio doesn’t look for references in the GAC:

  • http://blogs.msdn.com/msbuild/archive/2007/04/12/new-reference-assemblies-location.aspx
  • http://blogs.msdn.com/junfeng/archive/2004/03/22/93708.aspx

这是设计使然.

您可以显式添加文件,如果团队中的其他人已将文件安装在其他位置,则该文件将无效,例如C:\ Program Files \ NUnit 2.4.6与C:\ Program Files \ NUnit -2.4.6.或者(更具体地说,因为这是我今天早上遇到的问题),C:\ Program Files \ NUnit 2.4.6与C:\ Program Files(x86)\ NUnit 2.4.6.请注意(x86)–我的家用PC(截至上周末)正在运行Vista Ultimate x64.

You can either add your files explicitly, which doesn’t work if other people in your team have installed the files somewhere else, for example C:\Program Files\NUnit 2.4.6 vs. C:\Program Files\NUnit-2.4.6. Or (more specifically, because this is the problem I was having this morning) C:\Program Files\NUnit 2.4.6 vs. C:\Program Files (x86)\NUnit 2.4.6. Note the (x86) – my home PC is (as of last weekend) running Vista Ultimate x64.

您有两种选择:

  • 如果程序集还没有房屋,则可以将其放在VS PublicAssemblies文件夹中: http://support.microsoft.com/?kbid=306149 .
  • 如果您正在开发要供其他开发人员使用的程序集(即您是Microsoft或开发工具供应商),则可以将其放在C:\ Program Files \ Reference Assemblies目录的子目录中,然后将其添加到AssemblyFolders注册表项.
  • If your assemblies don’t already have homes, you can put them in the VS PublicAssemblies folder: http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245239.aspx
  • If they already have homes, you can add them to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders registry key: http://support.microsoft.com/?kbid=306149.
  • If you’re developing assemblies for other developers to use (i.e. you’re Microsoft or a development tool vendor), you can put these in a subdirectory of C:\Program Files\Reference Assemblies directory, and then add that to the AssemblyFolders registry key.

这意味着您的项目文件将按名称(即名称,版本,公钥令牌,所有jazz)引用程序集,而实际上在PC上的安装位置无关紧要.

This means that your project files will reference the assembly by name (i.e. name, version, public key token, all that jazz), and it won’t matter where it’s actually installed on your PC.

但是请注意,由于Visual Studio是32位应用程序,因此无法在64位上按原样运行.实际上,您实际上需要在HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ .NETFramework \ AssemblyFolders下注册您的东西,并且您可能应该在两个目录下都进行注册.

Note, however, that this doesn’t work as-is on 64-bit, because Visual Studio is a 32-bit application. You actually need to register your stuff under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\AssemblyFolders, and you should probably register under both.

这些密钥也有相应的HKEY_CURRENT_USER变体,但是(因为它是漫游的)所以用处不大(因为路径通常相对于机器而言).

There are also corresponding HKEY_CURRENT_USER variants of those keys, but (since that roams), it’s not much use (because the paths are usually relative to the machine, anyway).

这篇关于NUnit程序集如何出现在VS的“添加引用"中对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆