I haven't been able to find any references to using this combination of
technologies (remoting + generic methods + method overloading). I don't
think the problem has to do with C#, but I couldn't find a more
appropriate place to ask...
When I remotely try to call one of the methods in the object below, I
get an exception.
public class TestObj : MarshalByRefObject
{
public void TestMethod<T>(int a1, T a2) { }
public void TestMethod<T>(string a1, T a2) { }
}
The exception stack trace looks like this:
Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object.
Server stack trace:
at
System.Runtime.Remoting.Messaging.MethodCall.Resol veMethod(Boolean
bThrowIfNotResolved)
at System.Runtime.Remoting.Messaging.MethodCall..ctor (Object
handlerObject, BinaryMethodCallMessage smuggledMsg)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryMethodCall.ReadArray(Object[]
callA, Object handlerObject)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.Deser ializeBinaryRequestMessage(String
objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel
securityLevel)
at
System.Runtime.Remoting.Channels.BinaryServerForma tterSink.ProcessMessage(IServerChannelSinkStack
sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream
requestStream, IMessage& responseMsg, ITransportHeaders&
responseHeaders, Stream& responseStream)
I have tried both soap and binary formatters, tcp and http channels,
makes no difference. Also, the problem seems to occur no matter what I
do to the parameters - it seems the problem is with basic resolving of
generic methods. Furthermore, the overloading works fine when not used
across processes. It looks like somebody missed deserialization of
overloaded generic methods? There are no problems if the type parameter
is moved to the class instead of the methods.
/Mikkel Blanné