From: Ben Voigt [C++ MVP] on
�ystein Skotheim wrote:
> Ben Voigt [C++ MVP] wrote:
>
>>>>> Hello. I have problems with an applications consisting of mixed
>>>>> native and managed code writted in C++/CLI in Visual Studio 2005.
>>>>>
>>>>> The application runs fine in "Debug mode", however when I compile
>>>>> the application in "Release" mode I run into the following
>>>>> exception:
>>>>> [...]
>
>> Does the problem occur when a debugger is attached? The information
>> you gave is from the point that the .NET framework catches the
>> exception and pretty low quality. With a debugger attached, you'll
>> trap the first-chance exception, at the point where the AV actually
>> occurs.
>
> I run the program from within Visual Studio 2008 by clicking on "Start
> debug". Is this what you mean? Then I can step through the code. When
> I press F11 (Step Into) on the following code line, the exception
> saying access violation appears immediately in the output window of
> Visual Studio:
> MeasureDialog = gcnew GcpsDialog();
>
> even if I set a breakpoint on the first line of the constructor of
> GcpsDialog. (A strange thing is that GcpsDialog is actually a part of
> the main application and not a part of GcpsDotNetApi.dll - but the
> dialog contains member variables that references into the DLL file -
> so I guess this is the line of code that triggers loading of
> GcpsDotNetApi.dll)

Turn on mixed debugging, and goto Debug menu > Exceptions and make sure that
Win32 exception "Access violation" is set to break when thrown.


From: Øystein Skotheim on
Ben Voigt [C++ MVP] wrote:

>>>>>> Hello. I have problems with an applications consisting of mixed
>>>>>> native and managed code writted in C++/CLI in Visual Studio 2005.
>>>>>>
>>>>>> The application runs fine in "Debug mode", however when I compile
>>>>>> the application in "Release" mode I run into the following
>>>>>> exception:
>>>>>> [...]

>>> Does the problem occur when a debugger is attached? The information
>>> you gave is from the point that the .NET framework catches the
>>> exception and pretty low quality. With a debugger attached, you'll
>>> trap the first-chance exception, at the point where the AV actually
>>> occurs.

>> I run the program from within Visual Studio 2008 by clicking on "Start
>> debug". Is this what you mean? Then I can step through the code. When
>> I press F11 (Step Into) on the following code line, the exception
>> saying access violation appears immediately in the output window of
>> Visual Studio:
>> MeasureDialog = gcnew GcpsDialog();
>>
>> even if I set a breakpoint on the first line of the constructor of
>> GcpsDialog. (A strange thing is that GcpsDialog is actually a part of
>> the main application and not a part of GcpsDotNetApi.dll - but the
>> dialog contains member variables that references into the DLL file -
>> so I guess this is the line of code that triggers loading of
>> GcpsDotNetApi.dll)
>
> Turn on mixed debugging, and goto Debug menu > Exceptions and make sure that
> Win32 exception "Access violation" is set to break when thrown.

Hello again and thank you for your answer. I tried to do debug as you
suggested. Now the debugger stops on line 109 of file atonexit.c:

retval = __dllonexit(func, &onexitbegin, &onexitend);

This is the call stack:

ntdll.dll!RtlpNtMakeTemporaryKey() + 0x6a76 bytes
[Frames below may be incorrect and/or missing, no symbols loaded
for ntdll.dll]
ntdll.dll!RtlpNtMakeTemporaryKey() + 0x848f bytes
ntdll.dll!RtlInitializeSListHead() + 0x1075b bytes
msvcr80.dll!_msize() + 0xf8 bytes
msvcr80.dll!_invalid_parameter() + 0xf9 bytes
> GcpsDotNetApi.dll!_onexit(int (void)* func=0x04c70a3d) Line 110 +
0x10 bytes C
GcpsDotNetApi.dll!atexit(void (void)* func=0x04c70a3d) Line 127 +
0x9 bytes C
GcpsDotNetApi.dll!`dynamic initializer for 'afxModuleState''() Line
66 + 0x14 bytes C++
[Managed to Native Transition]
GcpsDotNetApi.dll!_initterm(void** pfbegin = 0x04C7134C, void pfend =
) Line 130 C++

GcpsDotNetApi.dll!<CrtImplementationDetails>::LanguageSupport::InitializeNative()
Line 534 C++

GcpsDotNetApi.dll!<CrtImplementationDetails>::LanguageSupport::_Initialize()
Line 680 C++

GcpsDotNetApi.dll!<CrtImplementationDetails>::LanguageSupport::Initialize()
Line 824 + 0x9 bytes C++
GcpsDotNetApi.dll!?.cctor@@$$FYMXXZ() Line 872 C++

Can you make any sense of it?

Regards,
--

�ystein Skotheim
Scientist, Optical Measurement Systems and Data Analysis
SINTEF ICT [http://www.sintef.com/omd]
From: Giovanni Dicanio on

"�ystein Skotheim" <oystein(a)dontspam.me> ha scritto nel messaggio
news:g6s7tf$a0n$1(a)kuling.itea.ntnu.no...

> 3DWorkBench.exe (C++/CLI) MFC in shared DLL CLR=Yes CRT=MT DLL
> AcqusitionLib.lib (C++) Standard Windows lib. CLR=No CRT=MT DLL
> GCPS.lib (C++) MFC in shared DLL CLR=No CRT=MT DLL

Would it be possible - at least for test - to try to set CLR support
"CLR=Yes" also in the GCPS.lib ?
The GCPS.lib is the only one to be in config state "MFC in shared DLL; CLR =
No".

Maybe some errors can occur if MFC in shared DLL is used, but modules with
CLR=No are linked with modules with CLR=Yes ?

Giovanni



From: Giovanni Dicanio on

"�ystein Skotheim" <oystein(a)dontspam.me> ha scritto nel messaggio
news:g6sikg$rra$1(a)kuling.itea.ntnu.no...

> I run the program from within Visual Studio 2008 by clicking on "Start
> debug".

> '<CrtImplementationDetails>.ModuleLoadException' occurred in msvcm80.dll

I read "msvcm80.dll" in your post ... But I think that if you use VS2008,
the number in the tail should be "90" (not "80")...

Are you mixing code and DLLs built with VS2008 with code and DLLs built with
VS2005?

Giovanni



From: Øystein Skotheim on
Giovanni Dicanio wrote:

>> I run the program from within Visual Studio 2008 by clicking on "Start
>> debug".
>
>> '<CrtImplementationDetails>.ModuleLoadException' occurred in msvcm80.dll
>
> I read "msvcm80.dll" in your post ... But I think that if you use VS2008,
> the number in the tail should be "90" (not "80")...
>
> Are you mixing code and DLLs built with VS2008 with code and DLLs built with
> VS2005?

Sorry, it was a typing error. I use VS2005, and all my code is compiled
with this version of Visual Studio. Thanks for being observant :-)

Regards,
--

�ystein Skotheim
Scientist, Optical Measurement Systems and Data Analysis
SINTEF ICT, Trondheim, Norway