NUnit 程序集如何出现在 VS“添加引用”中? 对话?
因此,安装 NUnit 后,程序集(nunit.framework
等)现在出现在 References > 中。 添加引用
对话框,但它们不在 %WINDIR%\Microsoft.NET\Framework\v2.0.50727
目录中,并且没有 NUnit
注册表项程序集路径(即 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramewokr\AssemblyFolder)
。
在 NUnit
安装目录的项目属性参考路径中也没有自动创建条目。 他们到底是怎么出现在“添加对话框”中的?!?! 我认为上述方式是程序集出现在“添加引用”中的唯一方式。
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)
.
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".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在周末对此进行了更深入的研究。 从我的 博客:
为什么 NUnit 不在 GAC 中? (或者为什么 [程序集 X] 没有出现在 Visual Studio 的“添加引用”对话框中?)
因为 Visual Studio 不会在 GAC 中查找引用:
这是设计使然。
您可以显式添加文件,但如果团队中的其他人已将文件安装在其他位置(例如 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) – 我的家用电脑(截至上周末)运行的是 Vista Ultimate x64。
您有几个选择:
这意味着您的项目文件将按名称(即名称、版本、公钥令牌、所有这些爵士乐)引用程序集,并且它实际安装在您的 PC 上的位置并不重要。
但请注意,这在 64 位上不起作用,因为 Visual Studio 是 32 位应用程序。 您实际上需要在 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\AssemblyFolders 下注册您的内容,并且您可能应该在两者下注册。
这些键也有相应的 HKEY_CURRENT_USER 变体,但是(因为它会漫游),它没有多大用处(因为无论如何,路径通常是相对于计算机的)。
I dug deeper into this at the weekend. Reproduced verbatim from my blog:
Why is NUnit not in the GAC? (or Why does [assembly X] not appear in Visual Studio's Add Reference dialog?)
Because Visual Studio doesn’t look for references in the GAC:
This is by design.
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.
You have a couple of options:
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.
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.
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).
奇怪的是,[HKEY_CURRENT_USER\SOFTWARE\Microsoft.NETFramework\AssemblyFolders] 应该是唯一驱动此问题的因素。
也许此页面中的这段代码是相关的?
如果安装 .NET Framework 3.0 Service Pack 1 (SP1),则会添加以下注册表子项:
如果安装 .NET Framework 3.5,则会添加以下注册表子项:
Strange, [HKEY_CURRENT_USER\SOFTWARE\Microsoft.NETFramework\AssemblyFolders] should be the only thing driving this.
Perhaps this snippet from this page is relevant?
If you install the .NET Framework 3.0 Service Pack 1 (SP1), the following registry subkey is added:
If you install the .NET Framework 3.5, the following registry subkey is added:
在我安装的 NUnit 中,我有一个注册表项,
它似乎是我计算机上此行为的驱动程序。 一旦我删除该键,引用就不会出现。
On my install of NUnit I have a registry key
It seems to be the driver of this behaviour on my computer. Once I removed that key the references did not appear.