简体   繁体   English

.Net无法解析棱镜模块引用的程序集

[英].Net can't resolve assemblies referenced by a Prism module

I have a Prism modular application, where modules are built in a directory catalogue. 我有一个Prism模块化应用程序,其中的模块构建在目录目录中。 If my module references an assembly, .Net assembly binder fails to locate that assembly at run time, because it is probing inside host applications bin folder, ignoring the modules bin folder altogether. 如果我的模块引用了一个程序集,则.Net程序集绑定程序在运行时无法找到该程序集,因为它正在主机应用程序的bin文件夹中进行探测,而完全忽略了模块的bin文件夹。 The only way to make it work is to reference the assembly in host app as well. 使其起作用的唯一方法是也要在宿主应用程序中引用程序集。 This is unacceptable IMO, because the whole point of a modular application is that the host app is decoupled from modules, hence it shouldn't be aware of what dlls they reference. 这是IMO不能接受的,因为模块化应用程序的全部要点是主机应用程序与模块分离,因此它不应该知道它们引用了哪些dll。

Is there a way to configure assembly loader/binder to look in the module's output folder for the referenced assemblies? 有没有一种方法可以配置程序集加载器/活页夹,以在模块的输出文件夹中查找引用的程序集?

I found this question, which doesn't give any solutions other than adding references in the host app. 我发现了这个问题,除了在主机应用中添加引用之外,它没有提供任何解决方案。

Prism assembly reference failure: System.Windows.Interactivity 棱镜程序集引用失败:System.Windows.Interactivity

I don't know if there is something out of the box in Prism, but you could manually implement something using AppDomain.AssemblyResolve event. 我不知道Prism中是否有任何现成的东西,但是您可以使用AppDomain.AssemblyResolve事件手动实现一些东西。

Diagnose using AssemblyLog 使用AssemblyLog诊断

Have you tried enabling assembly binding logging (FusionLog) to confirm it is definitely not looking in that folder already? 您是否尝试过启用程序集绑定日志记录(FusionLog)以确认它绝对不在该文件夹中?

See How to enable assembly bind failure logging (Fusion) in .NET how to enable it. 请参阅如何在.NET中启用程序集绑定失败日志记录(Fusion)

And Scott Hanselmans Blog for a tutorial on how to use it (in case you haven't used it before): Using Fusion Log Viewer to Debug Obscure Loader Errors 以及Scott Hanselmans Blog上有关如何使用它的教程(以防您以前没有使用过): 使用Fusion Log Viewer调试模糊的加载程序错误

AppDomain.AssemblyResolve Event AppDomain.AssemblyResolve事件

Have a look at MSDN: AppDomain.AssemblyResolve event, which an an example of dynamically loading a specific module can be found here: MS Docs: Resolving Assembly Loads 看一下MSDN:AppDomain.AssemblyResolve事件,可以在此处找到动态加载特定模块的示例: MS Docs:解决程序集加载

Note that you can get the requesting Assembly Name using ResolveEventArgs.RequestingAssembly which you could potentially use to figure out the folder to look for the assembly in. 请注意,您可以使用ResolveEventArgs.RequestingAssembly获得请求的程序集名称,您可能会用它来找出要在其中查找程序集的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我不能在我引用的程序集中添加一些程序集 - Why I can't add some assemblies to my referenced assemblies 使用引用但未使用的程序集(.net)进行编译 - Compile with referenced but unused assemblies(.net) prism:ViewModelLocator.AutoWireViewModel =“True”不适用于未引用的程序集 - prism:ViewModelLocator.AutoWireViewModel=“True” will not work for not referenced assemblies Windows服务和棱镜:服务参考棱镜组件可以吗? - Windows Services & Prism : Can the Service Reference Prism Assemblies? 控制何时加载引用的.NET程序集 - Control when referenced .NET assemblies are loaded .NET 4.0缺少引用的程序集文件夹 - Missing Referenced Assemblies Folder for .NET 4.0 从 .net 核心集成测试项目加载引用的程序集不包括来自测试的 API 的引用项目 - Load referenced assemblies from a .net core Integration Test project doesn't include referenced projects from tested API 从\\ localhost \ xyz启动时,.NET可执行文件不会加载引用的程序集 - .NET executable won't load referenced assemblies when started from \\localhost\xyz 我可以获取网站引用的所有程序集吗? - Can I get all assemblies referenced by a website 如何动态加载项目引用但代码未引用的程序集 - How can I dynamically load assemblies referenced by project, but not referenced in code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM