使用 VS2010 单元测试进行测试时,Unity 2 无法加载注册类型

发布于 2024-10-03 03:00:13 字数 687 浏览 1 评论 0原文

我已经使用应用程序配置设置了 Unity 2.0.414.0 容器。
我的解决方案结构如下所示:

项目 A:使用 Unity 和 Unity xml 配置文件的依赖项工厂。
项目B:Unity配置中使用的接口实现的几种类型。这些类型引用Microsoft.Sharepoint.dll
项目 C:Unity 的其他实现类型。没有引用 Sharepoint dll。

在 Visual Studio 2010 中执行单元测试期间,我遇到了问题。
当我尝试加载任何项目 B 类型的 Unity 配置时,它无法加载并导致整个容器的配置失败。
经过多次尝试解决问题设置并检查项目 BI 的引用后,发现如果我的所有程序集都安装在 GAC 中,Unity 可以正常工作。
如果我从 GAC 中删除它们,Unity 配置加载就会失败。

如果我尝试从简单的 Windows 应用程序调用 Unity Resolve 方法,则无论我的所有程序集是否都在 GAC 中,Unity 都会正常加载一切。

那么,我在 Visual Studio 测试配置中缺少哪些程序集解析器设置,以便 Unity 无需 GAC 部署即可运行?

I have set up an Unity 2.0.414.0 container using app config.
My solution structure looks like this:

Project A: dependency factory using Unity with unity xml config file.
Project B: Several types that are implementations of interfaces used in Unity config. These types reference Microsoft.Sharepoint.dll.
Project C: Other implementation types for Unity. No reference to Sharepoint dlls.

During the unit test execution in Visual Studio 2010 I have problems.
When I try to load my Unity configuration for any of Project B types it fails to load and causes the whole container to fail it's configuration.
After several attempts to solve the problem setting and checking the references of project B I noticed that Unity works fine if all my assemblies are installed in GAC.
If I remove them from GAC the loading of Unity config fails.

If I try and call the Unity Resolve method from a simple Windows application Unity loads everything fine regardless of whether all my assemblies are in GAC or not.

So what settings of assembly resolver am I missing in my Visual Studio Test configuration so Unity works without need of GAC deployment?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深陷 2024-10-10 03:00:13

我找到了我的问题。
我在 Visual Studio 测试的 Out 文件夹中丢失了几个输出文件。
我所要做的就是在测试设置中添加一个新的部署文件夹。
我转到 local.testSettings,然后选择“部署”,然后将我的 bin 文件夹添加为部署项。
现在,Visual Studio 将所有文件从 Bin 复制到 Out 文件夹,一切都非常顺利。
希望它能为像我一样情况的人节省一些时间:)

I have found my problem.
I was missing several output files in the Out folder of the Visual Studio test.
All I had to do was to add a new deployment folder in the Test settings.
I went to local.testSettings, then selected Deployment and then added my bin folder as deployment item.
Now Visual Studio copies all files from the Bin to the Out folder and everything works like charm.
Hope it will save some time to someone in the same situation like mine :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文