Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm working with the new dynaic type in .Net 4.0 . I try to send an object with .net Remoting without knowing his type using Reflection.
Here's the snippet of my remoting Client


Assembly ass = Assembly.LoadFile(assemblyPath);
dynamic crm =  ass.CreateInstance("CrmDll.CrmTiersFactory");
dynamic client = crm.getCrmClient(companyId);
TcpChannel tcp = new TcpChannel();
ChannelServices.RegisterChannel(tcp, false);
string url = "ServerUrl";
TypeConverter tc = TypeDescriptor.GetConverter(ass.GetType("CrmDll.IRemoteOperation"));
dynamic remoteOperation = tc.ConvertFrom( Activator.GetObject
                (
                ass.GetType("CrmDll.IRemoteOperation")
                , url
                ));

The interface IRemoteOperation used in Remoting is in the loaded Dll.
for the last line of snippet, I'v got the following NotSupportedException
can't convert from System.MarshalByRefObject with ReferenceConverter
Any idea ????
thanks
Posted
Updated 3-Feb-11 22:35pm
v2
Comments
Wild-Programmer 6-Feb-11 23:52pm    
Assembly ass is a good variable name :D
londhess 14-Mar-14 8:39am    
use "object" instead of dynamic keyword and check

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900