【发布时间】:2014-02-11 16:13:23
【问题描述】:
潜伏已久,第一次发帖。
背景:我有一个 asp.net webforms 应用程序,该应用程序当前引用包含各种 Web 控件的第三方程序集。第三方控件有时直接在各个页面上使用,或者是在其他地方使用的用户控件的一部分。该应用程序还利用了自定义服务器控件,这些控件也扩展了各种第三方控件。这些自定义控件也以类似的方式使用。
参考:Related Post,还有几个讨论程序集的多个版本,但我没有发现引用的程序集包含 web 控件。
问题:发现第三方控件之一与 IE10 存在问题。该问题已在最新版本的第三方程序集中得到解决。但是我无法将整个应用程序完全升级到第三方程序集的最新版本。
问题:是否可以同时运行两个版本的第三方程序集?
研究:我采用了其他几篇关于同一程序集的多个版本的帖子中提到的程序集绑定方法:
<dependentAssembly>
<assemblyIdentity name="thirdParty" publicKeyToken="XXX"/>
<codeBase version="OldVersion" href="bin"/>
<codeBase version="NewVersion" href="2013/ThirdParty.dll"/>
</dependentAssembly>
</assemblyBinding>
我还在项目文件中引用了这两个程序集,并为新版本的程序集设置别名:
<Reference Include="ThirdParty, Version=OldVersion, Culture=neutral, PublicKeyToken=XXX, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<HintPath>..\..\Library\ThirdParty.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ThirdParty, Version=NewVersion, Culture=neutral, PublicKeyToken=XXX, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<HintPath>2013\ThirdParty.dll</HintPath>
<Private>False</Private>
<Aliases>newVersion</Aliases>
</Reference>
在我要使用新版本控件的目标用户控件中,我有以下标记:
<%@Assembly Name="ThirdParty, Version=NewVersion, Culture=neutral, PublicKeyToken=XXX" %>
<%@Register tagPrefix="2013" namespace="ThirdPartyNamespace" Assembly="ThirdParty, Version=NewVersion, Culture=neutral, PublicKeyToken=XXX" %>
在设计器代码隐藏中,我有以下内容(newVersion 是分配给上述参考的别名):
extern alias newVersion;
protected newVersion::ThirdParty.ControlName cbRangeType;
一切都构建并运行,直到我到达 asp.net 编译器解析标记的部分。它因 CS0433 错误而失败。这几乎表明 cbRangeType 控件的类型存在于两个不同的地方。
\AppData\Local\Temp\Temporary ASP.NET Files\root\9f04cc99\85cc721e\assembly\dl3\5dc4ef04\77c80123_27b9ce01\ThirdParty.DLL
\WebSites\Site\2013\ThirdParty.dll'
查看生成的代码,发现控件类型不是使用newVersion别名,而是默认的全局别名:
Line 348: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
Line 349: private global::ThirdParty.ControlName @__BuildControlcbRangeType() {
Line 350: global::ThirdParty.ControlName @__ctrl;
我什至可以在用户控制级别覆盖调用 BuildControl() 生成的内容吗?我正在尝试做的事情甚至可能吗?提前致谢。
问候, 菜鸟
【问题讨论】: