NullReferenceException in Unknown Module

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Once in a while my application throws an NullReferenceException at startup,
however it appears to be occurring in an unknown module. If I debug it and
ask to 'break', then there is no source code available (I am running in Debug
mode of course).

What could be the cause of this? Can someone shed some light on this matter?

Kind regards,
 
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,
 
Once in a while my application throws an NullReferenceException at startup,
however it appears to be occurring in an unknown module.

Search the news groups for
"unknown module"
for some interesting reading (use the quotes to limit the responses)
 
Hi AMercer,

I've done that and indeed found some things, but none that really applies to
my specific problem. The only thing I could up with is that it could have
something to do with .NET SP1. The code ran smoothly without problems for the
past year running .NET SP0, the problems are very recent and since we
recently upgraded to SP1 that could have something to do with it.

Also people in the field claim they don't have the problem I'm stating. I
now notice that I only have this problem from the debugger...

Kind regards,
 
Also people in the field claim they don't have the problem I'm stating. I
now notice that I only have this problem from the debugger...

I believe it is a bug in the ide/debugger. When you have a situation that
exhibits the problem, try running the exe without using the ide/debugger. My
prediction is that you will never be able to recreate it that way. It is
nasty (assuming you have been seeing what I have seen) because it is rare and
intermittent.
The only thing I could up with is that it could have
something to do with .NET SP1.

I don't think sp1 has anything to do with it. Just my opinion, and the big
assumption is that you are seeing the same problem I have seen from time to
time.

Good luck.
 
AMercer said:
I believe it is a bug in the ide/debugger. When you have a situation that
exhibits the problem, try running the exe without using the ide/debugger. My
prediction is that you will never be able to recreate it that way. It is
nasty (assuming you have been seeing what I have seen) because it is rare and
intermittent.


I don't think sp1 has anything to do with it. Just my opinion, and the big
assumption is that you are seeing the same problem I have seen from time to
time.

Good luck.

Hi AMercer,

I get the same feeling now. I've tried running it outside the debugger
several times and couldn't reproduce it. Plus the fact that the program
doesn't have that problem in the field.

Thanks,
 
Back
Top