If I was to create a windows service, which in the background was making calls to the database and populating various objects. Is it then possible to access these objects from a standalone C# application? If so, how would I do this?
Thanks
If I was to create a windows service, which in the background was making calls to the database and populating various objects. Is it then possible to access these objects from a standalone C# application? If so, how would I do this?
Thanks
Simply you can use Named Pipes to make communication between two .Net applications.
This should be place inside Service to listen on client applications request
private static void SendByteAndReceiveResponse()
{
using (NamedPipeServerStream namedPipeServer = new
NamedPipeServerStream("test-pipe"))
{
namedPipeServer.WaitForConnection();
namedPipeServer.WriteByte(1);
int byteFromClient = namedPipeServer.ReadByte();
Console.WriteLine(byteFromClient);
}
}
and this will be inside Client applications
private static void ReceiveByteAndRespond()
{
using (NamedPipeClientStream namedPipeClient = new
NamedPipeClientStream("test-pipe"))
{
namedPipeClient.Connect();
Console.WriteLine(namedPipeClient.ReadByte());
namedPipeClient.WriteByte(2);
}
}
Note
Please do changes in
namedPipeClient.WriteByte(2);
according to your business logic.
OR
Please read this thread
Accessing objects strictly speaking is not possible. You can connect your apps with (for example) named pipes as per @Taha Sultan Temuri and serialize your objects, send over and deserialize them on the other end.