简体   繁体   English

适用于COM Dll的C#.Net包装器

[英]C# .Net Wrapper for COM Dll

Our new applications 1) web application (MVC3) 2) Webservices needs to communicate via interops with our COM based Business Layer 我们的新应用程序1)Web应用程序(MVC3)2)Web服务需要通过互操作与基于COM的业务层进行通信

We are planning to create a wrapper for the business layer in .Net to Decouple the COM dlls from the above 2 so that we have one place(wrapper) to make any enhancements or totally replace COM to something else. 我们计划在.Net中为业务层创建一个包装器,以将COM dll与上述两个解耦,以便我们有一个地方(包装器)进行任何增强或将COM完全替换为其他东西。

          For eg: if there is a COMClassA and ICOMClassA. create a new WrapperClassA in .Net which will essentially have an instance of the COMClassA and required properties. 

Use WrapperClassA in web application and webservices 在Web应用程序和Web服务中使用WrapperClassA

My question 1) Is this the right approach ? 我的问题1)这是正确的方法吗? 2) If so What is the best approach to create the .Net Wrapper. 2)如果是,创建.Net包装器的最佳方法是什么。
There are around 100+ Classes and corresponding interfaces for the COM dlls. COM dll大约有100多个类和相应的接口。 Any code generation techniques ? 任何代码生成技术?
3) Can we use some design patterns to minimize code generation or Is there any other alternate to decouple the COM Based Business Layer 3)我们可以使用某些设计模式来最大程度地减少代码生成,还是可以使用其他替代方法来使基于COM的业务层脱钩?

Please note: We don't want to create Web services and consume in ASP .Net Application since we believe there could be considerable performance issues. 请注意:我们不想创建Web服务并在ASP .Net应用程序中使用它,因为我们认为可能存在相当大的性能问题。

Any help will be greatly appreciated. 任何帮助将不胜感激。 Stackoverflow community you are doing a great job. 您在Stackoverflow社区做得很好。

TIA TIA

David Wheeler - 大卫·惠勒-

Any problem in computer science can be solved with another layer of indirection. 计算机科学中的任何问题都可以使用另一层间接解决。

I agree with the following statement in your question: 我同意您的问题中的以下声明:

We are planning to create a wrapper for the business layer in .Net to Decouple the COM dlls from the above 2 so that we have one place(wrapper) to make any enhancements or totally replace COM to something else. 我们计划在.Net中为业务层创建一个包装器,以将COM dll与上述两个解耦,以便我们有一个地方(包装器)进行任何增强或将COM完全替换为其他东西。

This allows you to "pick and choose" your problem areas, rewrite areas, or leave alone areas. 这使您可以“选择并选择”您的问题区域,重写区域或单独放置区域。 I can almost guarantee that at least one of your COM components executes some black magic... written by some ex-consultant or ex-employee five years ago... LOL 我几乎可以保证,您的COM组件中至少有一个能够执行某些黑魔法……这是五年前由某些前顾问或前雇员编写的……大声笑

Unfortunately as far as I know you will have to manually code/design your layer (or layers) of indirection. 不幸的是,据我所知,您将不得不手动编码/设计间接层。 However, some of the VS.NET (and Resharper and CodeRush) refactor/auto-generate methods will help you out a little. 但是,某些VS.NET(以及Resharper和CodeRush)重构/自动生成方法将对您有所帮助。 But at the end of the day you know your product (and design) better than anyone (or any tool). 但在这一天结束时,你知道你的产品(设计)比任何人(或任何工具)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM