07-31-2006 08:30 AM
namespace
TEGui.Server{
public class SyncAgent: MarshalByRefObject
{
public void HandleNumericStep(NationalInstruments.TestStand.Interop.API.SequenceContext seqcontext){
Do_Something(seqcontext);
}The server channel is then created using
{
BinaryServerFormatterSinkProvider
provider = new BinaryServerFormatterSinkProvider();provider.TypeFilterLevel =
TypeFilterLevel.Full; // IDictionary props = new Hashtable();
System.Collections.
IDictionary props = new Hashtable();props[
"port"] = 8085; TcpChannel channel1 = new TcpChannel(props,null,provider); ChannelServices.RegisterChannel(channel1); RemotingConfiguration.RegisterWellKnownServiceType( typeof(SyncAgent), "SyncServer", WellKnownObjectMode.SingleCall);public void MyProc(SequenceContext my_cont)
{
TcpChannel
channel1 = new TcpChannel(); ChannelServices.RegisterChannel(channel1); SyncAgent my_sync = (SyncAgent)Activator.GetObject(typeof(TEGui.Server.SyncAgent),"tcp://localhost:8085/SyncServer");//remote function
my_sync.HandleNumericStep(SeqcontextIn);
}
That's it - was supposed to work, by as soon the code runs, the client side throws the following exception as soon as //remote function part is reached
"The argument type "System.MarshalByRefObject cannot be converted to parameter type NationalInstruments.Interop...SequenceContext"
SequenceContext isn't derived from ISeralizable either, so i can't pass it by value.
Any suggestions ?
Please keep in mind that i HAVE to have a TestStand->Client Function->Server architecture and can't use TestStand->Server (i wish i could - it works !!)
Sagi
08-01-2006 08:57 PM - edited 08-01-2006 08:57 PM
Message Edited by Patrick P. on 08-01-2006 08:58 PM
08-02-2006 08:55 AM
Hi Pat,
thanks for answering me again.
Let me cletrify this - i am passing SequenceContext from TestStand to C# dll.
Now, from C# dll i want to pass it on to running C# program, using .Net remoting.
The remoting part is here :
TcpChannel channel1 = new TcpChannel();
ChannelServices.RegisterChannel(channel1);
SyncAgent my_sync = (SyncAgent)Activator.GetObject(typeof(TEGui.Server.SyncAgent),"tcp://localhost:8085/SyncServer");
while TEGui.Server.SyncAgent is a class, defined in an aseembly, common to client (the dll) and the server.
TEGui.Server.SyncAgent class has a function defined like this :
public void HandleNumericStep(NationalInstruments.TestStand.Interop.API.SequenceContext seqcontext)
So i am trying to call the function on the instance of SyncAgent object, i have created using .Net remoting on the client.
The problem is that SequenceContext object is neither derived from MarshalByRefObject nor implements ISerializable so it can't be
send to remote object by neither value nor reference.
Any ideas ?
Thnks,
Serge
08-15-2007 04:45 PM
Hiya,
Did you ever find a solution to this? Because this is the exact problem that I'm having, tried so many different ways of getting it to work now and about to give up and use sockets instead. Tried passing a class MashalByRef as you have, tried serialized and passing an enum getting various exceptions. Passing an enum I get an exception:
The argument type DefaultMsg cannot be converted into parameter type ConsoleApplication1.MessageType. (DefaultMsg is a member of the MessageType enum).
Thats just silly
Thanks
Mark
08-16-2007 01:16 AM
Mark,
I haven't been working with NI tools for like a year now - moved to RT embedded... Yet, from what I remember i found a way around it - i published methods that invoked the context on the local computer. This way, I didn't have to pass the context. I will search my PC @home for these old projects. Please do remind me about it next week and I will send you the project.
Serge
08-16-2007 12:53 PM
08-17-2007 08:56 AM
It's Correct !
This is the same thing that i did - two linked assemblies, so they both know the context !
Serge