当一个dll被引用但bin文件夹中存在多个版本时,aspx编译器将使用哪个dll
我有一个 ASP.NET Web 应用程序,它引用了“C:\references\Utils.Varia.dll”。引用的另一个 dll 使用此 dll 的签名版本(“C:\references\Utils.Varia.Signed.dll”)。
现在在我的 aspx 中我有以下导入指令: <%@ 导入命名空间="Utils.Varia" %>
此页面使用 Utils.Varia.StringExtensions 扩展类中的字符串扩展。
但在运行时我收到以下错误:
编译错误
描述:期间发生错误 所需资源的编译 来满足此请求。请查看 具体错误详情如下 并修改你的源代码 适当地。
编译器错误消息:CS0121: 之间的调用是不明确的 以下方法或属性: 'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(字符串, int)' 和 'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(字符串, int)'
所以我的猜测是编译器不知道是否从签名的或常规的 dll 中获取扩展方法。
这个假设是否正确?如果是,我如何将其指向正确的 dll?
[编辑]
奇怪的是,这个编译器错误只发生在 aspx 文件内的代码上。如果我在代码隐藏中使用相同的函数,一切都会按预期工作。有人可以解释一下吗?
另外,我不能只引用签名版本,因为实际使用签名版本是例外,所有其他组件都使用无符号版本(显然除了 1 之外)。
I have an ASP.NET Web Application which has a reference to 'C:\references\Utils.Varia.dll'. There is another dll referenced which uses the signed version of this dll ('C:\references\Utils.Varia.Signed.dll').
Now in my aspx i have the following imports directive:
<%@ Import Namespace="Utils.Varia" %>
This page uses a string extension from the Utils.Varia.StringExtensions extensionclass.
But at runtime I get the following error:
Compilation Error
Description: An error occurred during
the compilation of a resource required
to service this request. Please review
the following specific error details
and modify your source code
appropriately.Compiler Error Message: CS0121: The
call is ambiguous between the
following methods or properties:
'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string,
int)' and
'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string,
int)'
So my guess is that the compiler does not know whether to take the extension method from the signed or the regular dll.
Is this assumption correct and if so, how do I point it to the correct dll?
[Edit]
The weird thing is that this compiler error only happens on code inside the aspx file. If I use the same function in the codebehind, everything works as expected. Can someone explain this please?
Also, I can't just reference the signed version instead because actually using the signed version is the exception, all other components use the unsigned (apart from 1 apparently).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更改 Web 应用程序以引用签名版本。
Change the web app to reference the signed version.
看起来您费了很大的劲才故意在您的应用程序中复活“DLL Hell”,而默认情况下 .NET 可以轻松避免它。为什么同一应用程序中引用同一程序集的两个版本?
您需要删除这些引用之一(很可能,它必须是被删除的未签名引用),然后仅使用其中的代码。或者更改另一个,使其代码不同。
It looks like you've gone to a lot of trouble to purposefully resurrect "DLL Hell" in your app, when by default .NET makes it easy to avoid it. Why do you have two versions of the same assembly being referenced in the same application?
You need to remove one of those references (most likely, it must be the unsigned one that is removed), and just use the code from that. Or change the other one so its code is different.