删除互操作的 CompilerOptions 指令
我通过 tlbimp 为 COM dll 创建了一个互操作,并将其添加到程序集缓存中。 要在 ASP.net 页面中使用它,我需要包含以下内容:
<%@ Page Language="VB" Debug="true" CompilerOptions='/R:"C:\Program Files\blah\blah\LIBRARY.dll"'%>
<%@ Import Namespace=LIBRARY %>
如果它位于程序集缓存中,为什么我需要 CompilerOptions 指令? 我可以简化并集中这个吗?
I've created an interop for a COM dll via tlbimp
and added it to the assembly cache. To use this in an ASP.net page i need to include the following
<%@ Page Language="VB" Debug="true" CompilerOptions='/R:"C:\Program Files\blah\blah\LIBRARY.dll"'%>
<%@ Import Namespace=LIBRARY %>
Why do i need the CompilerOptions directive if it's in the assembly cache? Can i simplify and centralize this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够添加引用,就像添加任何其他程序集引用一样。 /R: 就是这样。
编辑:如果您没有在其他地方明确构建 Web 应用程序,那么在 aspx 文件中使用 /R 可能是您最好的选择。 您需要它的原因是 ASP.NET 正在为您有效地构建应用程序,并且需要告诉它要引用哪个库,即使该库位于 GAC 中。 它就像 Visual Studio 项目中的普通程序集引用一样 - 如果删除对 System.Xml 的引用,即使该程序集位于 GAC 中,您也将无法使用 XML 类。
You should just be able to add a reference just as you would add any other assembly reference. That's all /R: does.
EDIT: If you're not explicitly building the web app elsewhere, using /R in the aspx file is probably your best bet. The reason you need it is that ASP.NET is effectively building the application for you, and something needs to tell it which library to reference, even if that library is in the GAC. It's just like normal assembly references in a Visual Studio project - if you remove a reference to
System.Xml
, you won't be able to use the XML classes even though that assembly's in the GAC.