开发者

Single instance of a C# library across different processes

I have created a C# .Net WinForms project which uses few libraries which are also created by me. Now I am creating a COM wrapper and want to use the same libraries from an Excel file through VBA. But I do not want the Excel to create a new instance of the libraries. I need to use the same instance of the libraries which are loaded by the WinForms project. Please suggest a way.

WinForm App 
|- Library1.dll
|- Library2.dll 
. 
Excel
|-ComWrapper
|-Library1.dll 
|-Libr开发者_如何转开发ary2.dll

I have tried to explain the current situation diagrammatically. In the above case two instances of Library1.dll and library2.dll will be created as they are called from different processes. I need to have just one instance of library1.dll and library2.dll in the memory.


The only easily available way to achieve this is to register your COM wrapper as a COM+ object and configure it as a "Server application" in the "Activation" tab. You then need to use that COM+ object in both your winforms app and the Excel file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜