You'd need to study up on .NET Remoting... even if both exe's are on the same
machine. I think- if I understood your post correctly- that this is what
you're looking for. It's not difficult and it allows your exe to behave
similarly to a good ol' COM ActiveX EXE Server...
In the server EXE's Sub Main you'd do something like:
Dim TCPChannel As TcpChannel = New TcpChannel(49175) 'can be any port you want
ChannelServices.RegisterChannel(TCPChannel)
RemotingConfiguration.RegisterWellKnownServiceType (GetType(<YOURCLASS>),
"<SOME_NAME_TO_IDENTIFY_THIS_CONNECTION>", WellKnownObjectMode.SingleCall)
In the client you'd do something like this to call the exe:
Dim o As YOURCLASS = CType(Activator.GetObject(GetType(YOURCLASS),
"tcp://localhost:49175/<SOME_NAME_TO_IDENTIFY_THE_CONNECTION"), YOURCLASS)
'now use it like any ol' object
x = o.DoSomething()
Your class needs to inherit from MarshalByRef... and any types it returns
need to be serializable (most types are... but some aren't).
Also, there's the "gotcha" that the client needs to "know" what the class
is... so it needs to have a local reference to the server class. This defeats
the purpose of remoting because then you need a COPY of the server class on
the client even though it's actually executing somewhere else.... sooooo, the
easy solution is for YOURCLASS to imlement an Interface defined in a "shim"
dll that both client and server can share. The lightweight dll (containing
Interface definitions only) would then accomplish the same exact thing as a
Type Library (.tlb) in ol' COM or WSDL file in Web Services.
More info: check out:
http://msdn.microsoft.com/architectu...SecNetHT15.asp
"Ravi J" wrote:
Thanks Peter and CMM.
Peter, I thought about using a shared drive, but then I don'treally need
..NEt framework for this. I am wondering if some sort of queue can be
established between client and the server where in the server keeps writing
in and the clients keep reading.
CMM, Thx for the code snippet, but I am a little confused. How does the
client establish a connection to the file stream that the server (or windows
service) is writing to?
Back in the COM days, you could invoke a COM component running inside a
service and still be able to communicate as if it were a simple local
object. Can something like that be done using .NET? One possibility I see is
somehow add a reference inside the client for the service and use the class.
Would that be possible? And also, how to impliment it if both client and the
service are running in seperate user account?
Again, thanks for your replies (past/advance)
Ravi
"CMM" <CM*@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com... That's such an old school COBOL-esque way of doing things.
If you're transferring files between client/server via remothing you'd
just convert the filestream to a bytearray (code below) and return the
contents. If you're worried about first "loading the file into memory" or
whatever... consider this: this is pretty much exactly what the operating system does
even if you go the "polling" route suggested by others.
Dim fs As New System.IO.FileStream(theFile, IO.FileMode.Open,
IO.FileAccess.Read)
Dim bytes(CInt(fs.Length) - 1) As Byte '.length property is Long so it
needs to be cast
fs.Read(bytes, 0, CInt(fs.Length))
fs.Close()
Return bytes
then just reverse the process on the client side.
"Peter Rilling" wrote:
Do they have a common drive they can access? If so, you could just write the file to disk and then let the service pick it up at scheduled intervals.
"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> What is the best way to transfer files between two .NET executables?
> I have a service, and a client program. Client asks service for data. The > service creates one, and passes it back to client. Both programs run in ..NET
> framework.
> Given this requirement, how best to approach the issue? Does .NET
framework
> provides any class that can help?
> Thanks in advance,