calling methods of components running in windows service

G

Guest

I have written one Widows Service in ATL, having a ATL component running.
Now it is very easy to create the VC client by calling CoCreateINstanceEx to
create the component running in the service and giving the appropriate
machine where the service runs..
How shud I got about doing the same thing if the client is written in C#..
I tried using Remoting and ServiceController, but all in vein...
Firstly I wud like to know if it is possible to write such a client to ATL
service using C#.And if yes how shud I go abt it..

thanks
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Jasleen,

Create an interop assembly for the ATL service by using tlbimp.exe and
reference this assembly from your C# project.
This assembly will contain classes corresponding to the creatable coclasses
registered by the ATL service. You can instantiate them from managed code
just as any other classes.

You might want to refer to the MSDN COM Interop samples for better
understanding how COM servers are accessed by .NET clients.
 
G

Guest

I did that but how can I specify the machine name and other security
attributes while instantiating the server object.
I mean how do I tell on which machine the server exists...
For example following code will be there if I use the imported reference
ServerClass sc = new ServerClass();
But in the above instantiation I am unable to specify the machine name and
logon details etc..as u can do in CoCreateInstanceEx.
I hope I am able to put forth my problem..





Dmitriy Lapshin said:
Hi Jasleen,

Create an interop assembly for the ATL service by using tlbimp.exe and
reference this assembly from your C# project.
This assembly will contain classes corresponding to the creatable coclasses
registered by the ATL service. You can instantiate them from managed code
just as any other classes.

You might want to refer to the MSDN COM Interop samples for better
understanding how COM servers are accessed by .NET clients.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Jasleen said:
I have written one Widows Service in ATL, having a ATL component running.
Now it is very easy to create the VC client by calling CoCreateINstanceEx
to
create the component running in the service and giving the appropriate
machine where the service runs..
How shud I got about doing the same thing if the client is written in C#..
I tried using Remoting and ServiceController, but all in vein...
Firstly I wud like to know if it is possible to write such a client to ATL
service using C#.And if yes how shud I go abt it..

thanks
 
D

Dmitriy Lapshin [C# / .NET MVP]

Jasleen,

Here's an MSDN example for Media Services:

Type tServerType;
WMSServer RemoteServer;

// Retrieve the type information from the Windows
// Media server running on the remote machine.
tServerType = Type.GetTypeFromProgID("WMSServer.Server",
"remote_computer_name");

// Create an instance of the remote server object locally.
RemoteServer = (WMSServer)Activator.CreateInstance(tServerType);

Of course you should still have the interop library in place for the type
cast to work.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Jasleen said:
I did that but how can I specify the machine name and other security
attributes while instantiating the server object.
I mean how do I tell on which machine the server exists...
For example following code will be there if I use the imported reference
ServerClass sc = new ServerClass();
But in the above instantiation I am unable to specify the machine name and
logon details etc..as u can do in CoCreateInstanceEx.
I hope I am able to put forth my problem..





Dmitriy Lapshin said:
Hi Jasleen,

Create an interop assembly for the ATL service by using tlbimp.exe and
reference this assembly from your C# project.
This assembly will contain classes corresponding to the creatable
coclasses
registered by the ATL service. You can instantiate them from managed code
just as any other classes.

You might want to refer to the MSDN COM Interop samples for better
understanding how COM servers are accessed by .NET clients.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Jasleen said:
I have written one Widows Service in ATL, having a ATL component
running.
Now it is very easy to create the VC client by calling
CoCreateINstanceEx
to
create the component running in the service and giving the appropriate
machine where the service runs..
How shud I got about doing the same thing if the client is written in
C#..
I tried using Remoting and ServiceController, but all in vein...
Firstly I wud like to know if it is possible to write such a client to
ATL
service using C#.And if yes how shud I go abt it..

thanks
 
G

Guest

Thanks a lot....
I cud achieve my objective....


Dmitriy Lapshin said:
Jasleen,

Here's an MSDN example for Media Services:

Type tServerType;
WMSServer RemoteServer;

// Retrieve the type information from the Windows
// Media server running on the remote machine.
tServerType = Type.GetTypeFromProgID("WMSServer.Server",
"remote_computer_name");

// Create an instance of the remote server object locally.
RemoteServer = (WMSServer)Activator.CreateInstance(tServerType);

Of course you should still have the interop library in place for the type
cast to work.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Jasleen said:
I did that but how can I specify the machine name and other security
attributes while instantiating the server object.
I mean how do I tell on which machine the server exists...
For example following code will be there if I use the imported reference
ServerClass sc = new ServerClass();
But in the above instantiation I am unable to specify the machine name and
logon details etc..as u can do in CoCreateInstanceEx.
I hope I am able to put forth my problem..





Dmitriy Lapshin said:
Hi Jasleen,

Create an interop assembly for the ATL service by using tlbimp.exe and
reference this assembly from your C# project.
This assembly will contain classes corresponding to the creatable
coclasses
registered by the ATL service. You can instantiate them from managed code
just as any other classes.

You might want to refer to the MSDN COM Interop samples for better
understanding how COM servers are accessed by .NET clients.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

I have written one Widows Service in ATL, having a ATL component
running.
Now it is very easy to create the VC client by calling
CoCreateINstanceEx
to
create the component running in the service and giving the appropriate
machine where the service runs..
How shud I got about doing the same thing if the client is written in
C#..
I tried using Remoting and ServiceController, but all in vein...
Firstly I wud like to know if it is possible to write such a client to
ATL
service using C#.And if yes how shud I go abt it..

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top