Hi,
 
I'm trying to develop a script engine with debugging propabilites in Visual 
Studio in IronPython. My application is a client-server scenario. The scripts 
normally run hosted on a server and some objects like my OrderController are 
injected via ScriptScope and SetVariable method (this is my context of script). 
The server has access to the DB and so on. For debugging (on any developer 
machine) I connect via remoting to get an OrderController from server and try 
to inject this as SetVariable in script. My Problem is, that this doesn't work 
directly. Example:
 
// Get the OrderController (Proxy) via Remoting:
IOrderController service = 
(IOrderController)Activator.GetObject(typeof(IOrderController), 
"tcp://localhost:9898/Server/OrderController");


// Create scope and set OrderController as global variable:
ScriptScope scope = runtime.CreateScope();
scope.SetVariable("OrderController", service); // -> This throws an 
SerializationException because many classes are not marked as serializable!

 
// I have tried to unmarshal my OrderController (Proxy) and inject this 
serviceProxy. Example:
System.Runtime.Remoting.ObjectHandle handle = 
(System.Runtime.Remoting.ObjectHandle) service;
object unmarshaledService = 
System.Runtime.Remoting.RemotingServices.Unmarshal(handle.CreateObjRef(typeof(IOrderController)),true);
 
IOrderController serviceProxy = (IOrderController)unmarshaledService ;
scope.SetVariable("OrderController",serviceProxy);


This works for the OrderController, but not for another MarshalByRefObjects 
which are Members of the OrderController. In my example is the Member 
'SubObject' an another MarshalByRef object like the OrderController which has 
string Member 'Name'. Access in script to Member 'Name' fail. Example in python:
print OrderController.SubObject.Name // -> This throws an 
MissingMemberException. 'MarshalByRefObject' has no attribute 'Name'.

but in C# in my class which is hosting the script before I set the serviceProxy 
via SetVariable and run the script I can run 
Console.WriteLine(serviceProxy.SubObject.Name) without Problems.
 

What can I do? I wouldn't create the OrderController in script via remoting 
because Script should run without changes with OrderController as normal object 
and with OrderController as RemoteObject. So developer can directly publish 
there new scripts to server and any client can run this. Thanks

Best regards,
Thomas Joscht

_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to