简体   繁体   中英

How do I consume a COM+ local server from C#?

I have a web application from a company that has gone out of business. We're looking to extend the web app a bit with some asp.net functionality. The web app was written as an ISAPI application in Delphi, and uses COM+ to talk to the SQL Server and handles things like session management and authentication.

So, in order to get the current user and other details, I have to use the undocument COM+ components. I was able to dig out the type library and auto generated IDL, but at this point i'm lost in creating a .NET proxy class for this.

Is there a way to autogenerate the .net COM+ proxy either from the .dll itself (extracting the typelib info) or from the IDL?

Note: These seem to be simple COM style objects hosted in COM+ servers, no subscriptions or transaction monitoring..

You could use tlbimp.exe to generate C# proxy classes from your COM library.

tlbimp.exe myTest.tlb /out:myTest.dll

If you don't have the tlb it works also with COM dlls . Once the COM wrapper assembly generated you can reference it in your project and use the types inside as you would any other .NET class.

Possible location of tlbimp.exe : C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Bin\\TlbImp.exe or use the Visual Studio Command Prompt.

在类型库上运行Tlbimp.exe为其生成.NET互操作程序集。

Have you tried going to the references in your project, right clicking, add reference, then browsing to the dll. I think visual studio will generate the Runtime Callable Wrapper for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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