简体   繁体   English

每次升级我的dotNet应用程序使用的COM库时,是否需要重建和重新部署?

[英]Do I need to rebuild and redeploy every time I upgrade a COM library used from my dotNet app?

I have a C# .net 2.0 windows app that uses a COM component. 我有一个使用COM组件的C#.net 2.0 Windows应用程序。 Visual Studio 2005 automatically adds an interop assembly DLL when I add the reference to this COM library. 当我添加对此COM库的引用时,Visual Studio 2005会自动添加互操作程序集DLL。

In case the COM component is upgraded frequently, what do I need to do to keep my app upgraded too? 如果经常升级COM组件,我还需要做些什么来保持我的应用程序升级呢? Do I need to upgrade the interop DLL? 我是否需要升级互操作DLL? Do I need to rebuild and redeploy every time in order to keep up with the COM upgrade? 我是否每次都需要重建和重新部署才能跟上COM升级的步伐?

I don't understand 100% this interoperability issue, and I just need to minimize the work on every COM upgrade. 我不明白100%这个互操作性问题,我只需要最小化每次COM升级的工作。 I need to avoid rebuilding and redeploying every time. 我每次都需要避免重建和重新部署。 Is there any optimal way to achieve this? 有没有最佳方法来实现这一目标?

I've been reading Advanced COM Interoperability ( http://msdn.microsoft.com/en-us/library/bd9cdfyx.aspx ) in MSDN and still don't have clear answer. 我一直在MSDN中阅读高级COM互操作性( http://msdn.microsoft.com/en-us/library/bd9cdfyx.aspx ),但仍然没有明确的答案。

Thanks in advance 提前致谢

You should not need to update the interop DLL, as long a the COM interface of the component does not change. 只要组件的COM接口没有更改,您就不需要更新互操作DLL。 Thus, it depends on what kind of changes are being made to the component. 因此,它取决于对组件进行何种更改。

Release notes would be the obvious source of information. 发行说明将是明显的信息来源。 Failing that, comparing .tlb files (if they are delivered with the component) might be an option. 如果做不到这一点,那么比较.tlb文件(如果它们与组件一起交付)可能是一种选择。

Potentially, the component might support multiple interface versions as well, which would make it unnecessary to update your application immediately. 潜在地,该组件也可能支持多个接口版本,这使得不必立即更新您的应用程序。

and can't find any tlb file for the COM in question. 并且找不到有问题的COM的任何tlb文件。

It is normally embedded in the COM server DLL. 它通常嵌入在COM服务器DLL中。 Something you can see with Visual Studio, File + Open + File and select the DLL. 您可以使用Visual Studio,File + Open + File查看并选择DLL。 You'll see a TYPELIB node, resource 1 is the type library. 您将看到TYPELIB节点,资源1是类型库。

You can decompile the type library by running Oleview.exe from the Visual Studio Command Prompt. 您可以通过从Visual Studio命令提示符运行Oleview.exe来反编译类型库。 File + View Typelib and select the DLL. 文件+查看Typelib并选择DLL。 Copy/paste the content of the right pane into a text editor and save it. 将右窗格的内容复制/粘贴到文本编辑器中并保存。 If there is any change in this IDL then you must rebuild the import library and your program. 如果此IDL有任何更改,则必须重建导入库和程序。 Not doing so can cause very difficult to diagnose runtime problems that include access violation exceptions and calling the completely wrong method. 不这样做会导致很难诊断包含访问冲突异常和调用完全错误方法的运行时问题。

This is hard to automate, clearly you'll prefer a better way for the vendor to let you know about breaking changes. 这很难实现自动化,显然您更愿意让供应商更好地了解有关更改的信息。 The programmer that worked on this server should be well aware of the need for this. 在这台服务器上工作的程序员应该非常清楚这需要它。

When I am doing COM interop with a component that I might be making lots of builds of, but the COM component isn't changing all that often, then i'll use TLBIMP to make a Interop that I just reference my interop that I can do versioning on (although to version the Interop may require .NET4). 当我正在使用我可能正在制作大量构建的组件进行COM互操作时,但是COM组件并没有经常更改,那么我将使用TLBIMP制作一个Interop,我只是引用我的互操作,我可以做版本控制(尽管版本的Interop可能需要.NET4)。

Make all the following a batch file (single line) and use the appropriate tlbimp. 将以下所有内容作为批处理文件(单行)并使用适当的tlbimp。

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\tlbimp" 
"C:\pathtocomdll\comcomponent.dll" 
/out:"Interop.mycomponent.dll" 
/asmversion:"1.1.0.0" /keyfile:"\\server\keyfiles\library.snk"  
/company:"my company"  /productversion:"1.1.0.0" 
/copyright:"2013" 
/product:"company product" /namespace:"company.namespace"

If the COM Component you are using is just upgrading their version but not changing their interface, then you shouldn't need to rebuild your Interop. 如果您使用的COM组件只是升级其版本但不更改其界面,则您不需要重建Interop。 If you are using .net4 you can also embed the interop in your project. 如果您使用.net4,您还可以在项目中嵌入互操作。

暂无
暂无

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

相关问题 如何代理在docker容器中运行的dotnet核心应用程序的每个请求 - How do I proxy every request from a dotnet core app running in a docker container 我是否需要在每次“foreach”迭代时释放 COM 对象? - Do I need to release the COM object on every 'foreach' iteration? VS2010:每次重建时都必须不断复制我的PDB文件 - VS2010: Have to constantly copy over my PDB files every time I rebuild 位于服务器上的Win32控制台应用程序,是否需要重建才能更新app.config? - Win32 console app living on server, do I need to rebuild in order to update app.config? 如何列出 Dotnet 库的 API? - How do I list the API of a Dotnet library? 我想每分钟运行一个从我的 OnAppearing() 开始的方法。 我需要将此作为任务运行吗? - I want to run a method every minute that's started from my OnAppearing(). Do I need to run this as a task? 更改web.config中的任何内容后是否需要重建解决方案? - Do i need to rebuild my solution after changing anything in web.config? C# selenium chrome 驱动程序,每次我运行我的程序时我都需要从我的手机扫描二维码 - C# selenium chrome driver, every time I run my program I need to scan QR code from my mobile 使用“dotnet new react -o my-app”中的默认代码时,为什么会出现 JSON.parse 错误? - Why do I get JSON.parse error when using default code from “dotnet new react -o my-app”? 我的数据库的每个表都需要一个类吗? - do I need a class for every table for my db?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM