Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing SequenceContext object as parameter to remote function

Hi Guys,
 
I have a remoting architecture, in which a client function is executed by TestStand just to pass a sequence context to running Server.
This can be done directly from TestStand (and even works perfectly), but i need an external dll for purposes on exception handling etc.\
The code looks like this :

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);

}
 
The client side looks like this
 

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

 

 

 

 

 
0 Kudos
Message 1 of 7
(5,487 Views)
Hi Sagi,

Just a few questions.  If I understand you correctly, you are calling some .NET code from TestStand in which you are passing the sequence context into.  Then from this code you are trying to pass the sequence context object to another external dll? 

In your code for the client you are passing SeqcontextIn into the HandleNumericStep function.  Is this defined further up in your code somewhere because I didn't see any definition for it?  Also what versions of TestStand and Visual Studio is this all being developed in?

Message Edited by Patrick P. on 08-01-2006 08:58 PM

Pat P.
Software Engineer
National Instruments
0 Kudos
Message 2 of 7
(5,470 Views)

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

 

0 Kudos
Message 3 of 7
(5,466 Views)

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

0 Kudos
Message 4 of 7
(5,038 Views)

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

0 Kudos
Message 5 of 7
(5,031 Views)
Hiya,
 
Thanks, I've been working on the problem with some colleges at work today and we found a solution 🙂 I had 2 assemblies, one for the client and one for the server then the RemoteObject .cs was in the server assembly and linked into the client assembly. So the client and server knew about the remote object but they as far as Remoting was concerned they might not be the same, so I moved the remote object .cs into its own Assembly dll and then linked it in with both client and server and then it all magically worked 🙂
 
You might of found the same solution, but at least its here in the forums now incase anyone else is interested 🙂
 
Thanks
 
Mark
0 Kudos
Message 6 of 7
(5,001 Views)

It's Correct !

 

This is the same thing that i did - two linked assemblies, so they both know the context !

Serge

0 Kudos
Message 7 of 7
(4,958 Views)