c# – 将.NET程序集引用解析为其他名称?
发布时间:2020-12-15 07:44:35 所属栏目:百科 来源:网络整理
导读:我的项目引用了Library1.dll和Library2.dll. Library2.dll依赖于Library1.dll,但它被编译为以不同的名称Library1.Net40.dll引用它. 是否有一种很好的方式告诉我的应用程序重定向Library1.Net40.dll的所有引用以解析为Library1.dll?也许类似于使用 bindingRe
我的项目引用了Library1.dll和Library2.dll. Library2.dll依赖于Library1.dll,但它被编译为以不同的名称Library1.Net40.dll引用它.
是否有一种很好的方式告诉我的应用程序重定向Library1.Net40.dll的所有引用以解析为Library1.dll?也许类似于使用< bindingRedirect>?重定向版本的方式 我有一个处理AppDomain.AssemblyResolve事件的解决方案,但它有点像黑客,我希望有更好的方法来做到这一点. 编辑: 解决方法
你试过玩
<codeBase> element吗?
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Library1.Net40" publicKeyToken="..." culture="neutral" /> <codeBase version="2.0.0.0" href="Library1.dll"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration> (未经测试;不知道是否有效.) CF:我把这个更新放在这里,因为评论有点长:) 好主意,谢谢.我得到重定向工作,但它抱怨因为名称不同,这是日志: LOG: Attempting download of new URL file:///C:/Project/bin/Library1.dll. LOG: Assembly download was successful. Attempting setup of file: C:ProjectbinLibrary1.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: Library1,Version=3.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed WRN: Comparing the assembly name resulted in the mismatch: NAME ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |