[Mono-dev] Embeded : NullReferenceException not raised when using managed null objects on Windows

Robert Jordan robertj at gmx.net
Thu Jan 21 16:26:20 EST 2010


On 21.01.2010 21:41, Damien wrote:
>> Hi,
>
>>>
>>> I am using Windows 7 x86, Visual Studio 2008, Mono 2.6.1 embeded
>> (installed
>>> from windows setup).
>>>
>>> When I should have a NullReferenceException (bug in code), a managed
>>> NullReference is not thrown, but a native error occurs (Access violation,
>>> memory 0x00000000).
>>
>> Are you seeing this while debugging the application or at runtime?
>> It should not happen at runtime given your OS and compiler.
>>
> I have this error while debugging the application (attaching to process
> that uses my code).

This is by design. IIRC, the VS debugger can be configured to ignore
this kind of exceptions.

> Without a debugger attached, it simply crashes.

This could be another unrelated crash.

Insert a DebugBreak() Win-API call right after

     MonoObject* ret = mono_runtime_invoke(methodHandle, target, args,
&exception);
     DebugBreak();

in your code and run the app w/out a debugger.

When the breakpoint is reached, the just-in-time debugger should pop
up automatically, unless the reason of the crash was
mono_runtime_invoke or some other call before.

Robert



More information about the Mono-devel-list mailing list