Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing a .Net Service

Tags:

c#

.net

service

com

I have written a Windows Service in .Net and I want to expose the classes to be called by other .Net code. Specifically, I have an API that I want to expose via a DLL that will be placed in the GAC, and I want the DLL in the GAC to use the classes of the .Net Windows Service. I need this architecture as the code in the Windows Service needs to be run as a different user/account as the caller of the API (the account would be created at install time).

My plan was to expose the Windows Service classes via COM (regasm.exe to register and tlbexp.exe to create the type library), and then call the classes in the GAC DLL via COM (imported via tlbimp.exe). However I get the following error from tlbimp:

TlbImp : error TI0000 : System.Runtime.InteropServices.COMException - Type library '' was exported from a CLR assembly and cannot be re- imported as a CLR assembly.

This implies to me that my method is not going to easily work. I can only think that I might need a C++ DLL as a bridge for my GAC DLL to invoke the COM calls, but this seems like a nasty solution.

I am basically looking for suggestions. Does anyone know how to expose classes of a Windows Service written in .Net to other .Net code?

like image 571
Dave Avatar asked Nov 15 '22 11:11

Dave


1 Answers

You might want to have a look at using Remoting

like image 153
Adriaan Stander Avatar answered Dec 11 '22 22:12

Adriaan Stander