Hi,
I've investigated a little further, and I think that the exception is thrown
from or near the System.Runtime.Remoting dll. I've checked this by setting
breakpoints once this NullReferenceException occurs, and pressing continue.
The point where execution breaks is right after a call to
RemotingServices.Connect.
This problem occurs once in a while (unpredictable), but doesn't happen at
all if I put a breakpoint at the line where the connection is made using
RemotingServices.Connect and continue execution from there. I suspect a
timing/sync problem when loading the System.Runtime.Remoting assembly dll
although this is just a wild guess.
I'm running .NET 1.1.4322/SP1 on a WinXp-Pro 5.1.2600/SP1 platform. The
program is compiled using C# on MSDE 2003 7.1.3088.
The code snippet where the problem occurs follows. After pressing continue
for the NullReferenceException and setting breakpoints, execution stops at
the third line where I cast the remoted object reference to the interface,
right after the call to RemotingServices.Connect. So my guess is that the
exception is triggered somewhere around the call to RemotingServices.Connect.
Since the NullReferenceException occurs in an unknown module my (wild) guess
is that loading the Remoting assembly produces the problem (this is the first
call to the Remoting library from my program).
<code>
string connectionStr="tcp://localhost:9123/MyRemoteObj";
object objRef = RemotingServices.Connect (
typeof( IMyItf ),
connectionStr
); // <-- NullReferenceException here???
IMyItf myRemoteObj = objRef as IMyItf;
</code>
Kind regards,