使用 Prism Modularity 并按源包含 Unity 时出现 Unity 容器错误
当尝试将 Prism4 Bootstrapper 与源引用的 Unity 一起使用(将现有项目包含到解决方案中)时,我不断收到错误。我还从源代码构建 Unity 然后包含输出文件时遇到错误。
详细信息如下:
我有一个使用 Prism4 的项目。 Prism 的 Bootstrapper 组件依赖于 Unity 2.0。更准确地说,它们依赖于 Unity 2.0.414.0 版本。
如果我尝试将当前版本或更新版本的 Prism 作为 prism 4 包含到我的项目中,那么 VS 会向我发送一条消息,要求我生成一些 app.config 代码,强制加载最新的程序集。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.505.0" newVersion="2.1.505.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
当使用 Unity 2.0 和 Unity 2.1 的预构建 dll 文件时,这可以正常工作...
但是,如果我尝试从源代码构建这些文件并使用新的 DLL ,或将项目直接包含到我的项目中我总是收到错误:
The type 'Microsoft.Practices.Unity.IUnityContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
请注意,Unity 2.0 [b]IS[/b] 版本 2.0.414.0。所以我的第一次尝试是使用 unity 2.0 源代码库。我还使用这个版本进行了许多后续尝试,包括从一个新项目开始。我尝试过通过预构建的 bin 文件、源代码和自定义构建的 dll 来包含 Prism,但结果相同。我还使用 Unity 2.1 尝试了所有相同的操作,希望它能起作用。
我的环境是MSVC#2010 win7 x64。我在 x86 和任何 CPU 配置下构建以及调试和发布。唯一的依赖项是 Prism 和 Unity。
I keep getting an error when trying to use Prism4 Bootstrapper with Unity referenced by source (include existing projects into the solution). I also get an error building Unity from source and then including the output files.
Here's the details:
I've got a project using Prism4. The Bootstrapper component for Prism relies on Unity 2.0. To me more precise they rely on Version 2.0.414.0 of unity.
If I try to include the current or a newer version of Prism into My project as prism 4, then VS gives me a message to generate some app.config code that forces the loading of the newest assembly.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.505.0" newVersion="2.1.505.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
When using the prebuilt dll files for Unity 2.0 and Unity 2.1, this works without a problem...
However, if I try to build these from source and use the new DLLs, or include the projects directly into my project I always get the error:
The type 'Microsoft.Practices.Unity.IUnityContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Mind you that Unity 2.0 [b]IS[/b] version 2.0.414.0. So my very first attempt was by using the unity 2.0 source base. I have also made many subsequent attempts using this version, including starting from a fresh project. I've tried including Prism by pre-built bin files, source, and custom built dlls with the same result. I've also tried all of the same things using Unity 2.1 in hopes it might work.
My environment is MSVC# 2010 win7 x64. I've built under x86 and Any CPU configurations as well as both debug and release. The only dependencies are Prism and Unity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了解决方法。
我打开了 Prism 源的解决方案并删除了任何对 unity 的引用。然后我将 Unity 项目作为现有项目添加到 Prism 解决方案中。最后,我将统一作为所有相关棱镜项目的一个项目。因此,我将在项目中使用的 unity dll 由 prism unityextensions 输出。
稍后更新一些批处理文件,瞧,这是一个解决方法。
这不是最好的解决方案,但我现在准备好继续前进。
PS 主题行不正确。这是 prism 中 UnityExtensions 的问题,而不是模块化的问题。当我调用 UnityBootstrapper 时,我也不清楚它“
Found a workaround.
I opened the solution for the Prism source and removed any references to unity. Then I added the unity project as an existing project to the prism solution. Lastly I referenced the unity as a project for all concerned prism projects. So the unity dll that I'm going to use for my project is being output by the prism unityextensions.
Some batch file updates later and voila, a workaround.
Not the best solution but I'm ready to move on now.
P.S. The subject line is incorrect. This is an issue with UnityExtensions in prism, not modularity. Also I wasn't clear about the UnityBootstrapper when I called it "