473,658 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mixing manged and unmanaged code with DLL leads to HRExeception at start

Hello,

I'm new to the realm of .NET application creation, so please forgive
my ignorance.

I have been tasked with debugging a problem that arises with using a
DLL that contains managed and unmanaged code in concert with a managed
application that makes calls to the DLL. This problem has been
cropping up for a while, but the debugger provides very little
information (from what I can tell) as to what exactly is the problem.

During application load, I get a dialog before getting into main:

First-chance exception at 0x7c812a5b in FormatConvertor d.exe:
Microsoft C++ exception: HRException at memory location 0x0012e74c..

The break shows up here:

mcrtexe.cpp:323
if defined (_MANAGED_MAIN)
__set_managed_a pp_type();
mainret = main(arguments) ;
#else /* defined (_MANAGED_MAIN) */

If I ignore, I get a couple more dialogs with worsening messages
before the application quits:

First-chance exception at 0x7c812a5b in FormatConvertor d.exe:
Microsoft C++ exception: [rethrow] at memory location 0x00000000..

First-chance exception at 0x7c98eafa in FormatConvertor d.exe:
0xC0000025: Windows cannot continue from this exception.

A first chance exception of type
'System.Runtime .InteropService s.SEHException' occurred in
FormatConvertor d.exe Additional information: External component has
thrown an exception.

I scoured Google for similar text, but only found a handful of
articles with the same text as mine. I have _no idea_ a) what type of
exeception this is
b) where exaclty in the code this is being triggered (as it's before
main, and the call stack doesn't have a lot of places to break into)
c) how to debug this and find out what's causing the problem.

I know this is vague, but I'm guessing it has something to do with
adding the DLL into my managed application, and not setting up
something correctly in the manifest/dependencies/build settings??

I'm really out on a limb, and would be grateful for any insight anyone
has. Also, please forgive if this is the not the best newsgroup for
this type of problem. If so, I'd be much obliged if someone could
point me to a better newsgroup.

Thanks!!

Here is the console text:

'FormatConverto rd.exe': Loaded 'D:\Bin\FormatC onvertord.exe', Symbols
loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\ntdll.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\mscoree.d ll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\kernel32. dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\advapi32. dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\rpcrt4.dl l', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. VC80.DebugCRT_1 fc8b3b9a1e18e3b _8.0.50727.762_ x-
ww_5490cd9f\msv cr80d.dll', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\msvcrt.dl l', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. VC80.DebugCRT_1 fc8b3b9a1e18e3b _8.0.50727.762_ x-
ww_5490cd9f\msv cp80d.dll', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\user32.dl l', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\gdi32.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\ole32.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\shlwapi.d ll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\d3d9.dll' , No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\d3d8thk.d ll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\version.d ll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\winmm.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\d3dx9_33. dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\comdlg32. dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\comctl32. dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\shell32.d ll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. VC80.DebugCRT_1 fc8b3b9a1e18e3b _8.0.50727.762_ x-
ww_5490cd9f\msv cm80d.dll', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\imm32.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\lpk.dll', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\usp10.dll ', No
symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. Windows.Common-
Controls_6595b6 4144ccf1df_6.0. 2600.2982_x-ww_ac3f9c03\com ctl32.dll',
No symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Mic rosoft.NET\Fram ework
\v2.0.50727\msc orwks.dll', No symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. VC80.CRT_1fc8b3 b9a1e18e3b_8.0. 50727.762_x-
ww_6b128700\msv cr80.dll', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Mic rosoft.NET\Fram ework
\v2.0.50727\Cul ture.dll', No symbols loaded.
'FormatConverto rd.exe': Unloaded 'C:\WINDOWS\Mic rosoft.NET\Fram ework
\v2.0.50727\Cul ture.dll'
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\ass embly
\NativeImages_v 2.0.50727_32\ms corlib\31bae188 08fa8d45ad26959 f0c9bfd5f
\mscorlib.ni.dl l', No symbols loaded.
'FormatConverto rd.exe' (Managed): Loaded 'C:\WINDOWS\ass embly
\GAC_32\mscorli b\2.0.0.0__b77a 5c561934e089\ms corlib.dll', No symbols
loaded.
'FormatConverto rd.exe' (Managed): Loaded 'd:\p4_dc01666_ UZURA\Program
\Suite102\Bin\F ormatConvertord .exe', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Mic rosoft.NET\Fram ework
\v2.0.50727\msc orjit.dll', No symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\Mic rosoft.NET\Fram ework
\v2.0.50727\dia symreader.dll', No symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\sys tem32\rsaenh.dl l', No
symbols loaded.
'FormatConverto rd.exe' (Managed): Loaded 'C:\WINDOWS\Win SxS
\x86_Microsoft. VC80.DebugCRT_1 fc8b3b9a1e18e3b _8.0.50727.762_ x-
ww_5490cd9f\msv cm80d.dll', Symbols loaded.
'FormatConverto rd.exe': Loaded 'C:\WINDOWS\ass embly
\NativeImages_v 2.0.50727_32\Sy stem
\c78e3732b90739 46b6f8e816d9b1a c85\System.ni.d ll', No symbols loaded.
'FormatConverto rd.exe' (Managed): Loaded 'C:\WINDOWS\ass embly\GAC_MSIL
\System\2.0.0.0 __b77a5c561934e 089\System.dll' , No symbols loaded.
'FormatConverto rd.exe': Loaded 'D:\Bin\FormatC onvertorDllDebu g.dll',
Symbols loaded.
'FormatConverto rd.exe': Unloaded 'D:\Bin\FormatC onvertorDllDebu g.dll'
First-chance exception at 0x7c812a5b in FormatConvertor d.exe:
Microsoft C++ exception: HRException at memory location 0x0012e74c..
C:\WINDOWS\syst em32\d3dx9_33.d ll: No symbols loaded.
C:\WINDOWS\syst em32\d3dx9_33.d ll: No symbols loaded.
C:\WINDOWS\syst em32\d3dx9_33.d ll: No symbols loaded.
First-chance exception at 0x7c812a5b in FormatConvertor d.exe:
Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x7c98eafa in FormatConvertor d.exe:
0xC0000025: Windows cannot continue from this exception.
First-chance exception at 0x7c98eafa in FormatConvertor d.exe:
0xC0000025: Windows cannot continue from this exception.
First-chance exception at 0x7c98eafa in FormatConvertor d.exe:
0xC0000025: Windows cannot continue from this exception.
A first chance exception of type
'System.Runtime .InteropService s.SEHException' occurred in
FormatConvertor d.exe

Additional information: External component has thrown an exception.

An unhandled exception of type
'System.Runtime .InteropService s.SEHException' occurred in
FormatConvertor d.exe

Additional information: External component has thrown an exception.

The thread 'Win32 Thread' (0xc7c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x968) has exited with code 0 (0x0).
The program '[3788] FormatConvertor d.exe: Managed' has exited with
code 0 (0x0).
The program '[3788] FormatConvertor d.exe: Native' has exited with code
0 (0x0).

<< cross-posted to dotnet.framewor k, sorry >>

May 30 '07 #1
0 2932

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2843
by: kaalus | last post by:
Hello I have problem mixing managed and unmanaged C++ code in VS.NET 2003. I want to create a windows forms application which uses some C++ code that is incompatible with managed extensions (__fastcall etc.). I have tried disabling "compile as managed" option for these specific files, but it does not help: by trial and error I figured out that if there are any "references" in the project, IDE adds /FU switch with each of these references to...
2
489
by: Neil | last post by:
I am developing a demo in C# using Managed DirectX. I wanted to use a C++ static library in the demo (its a class for handling physics), so I decided to create my Graphics classes in C#, inherit from them in MC++. So far so good...... I modified my MC++ project to run as mixed mode (removed nochkclr.obj, added msvcrt.lib, etc etc), and created 2 unmanaged classes which handled the calls to the static lib (btw all the code works fine in...
0
242
by: P Reddy | last post by:
Hi All, Greetings!!! I have a question. Please respond.... I am trying to write a C# component that need to inherit some of the the interfaces from unmanged code(VC). I think one way to resolve this is to port unmanged interfaces and header files in to manage C++ as Visual Studio allows porting and compiling all this
2
1787
by: MR | last post by:
help! I have an unmanaged DLL that I do not have the source code, so i can't recompile or make changes. the DLL requires a callback function. I would like to implement the callback method in a managed class. The unmanaged DLL gets the address of the callback in a struct (someStruct below) that is passed as a parameter. I can't seem to figure out how to pass the "unmanaged" address of a managed method to be uses as a callback. I would...
1
904
by: al | last post by:
Hi, I'm very confused about the following: Can someone please explain the difference between Type and Strong Typed Data and if there is untyped data in the Managed Code, and how this relates to earyl and latte bindings? Also, what is the defference between close and dispose and how they relate to Finalize argument? MTIA,
4
1797
by: gabe | last post by:
i have a solution to gather the text in each window that is open, but would rather use only managed code rather than unmanaged code my current solution relies on. The purpose is to get the text in each open window even/especially for child windows in other non managed mdi apps - if excel has 3 books open or any other mdi app has several windows open, I'd like the complete text from each window. The current solution gives me more info...
2
16850
by: jraul | last post by:
Hi, This is probably a noobie question but: I just created a new C++/CLI project in VS 2005. It created an empty class: public ref class Class1 { // TODO: Add your methods for this class here.
2
3147
by: Cartoper | last post by:
I am working in VS2005 (.Net 2.0). I have a unmanaged C++ class that will be used by C#, once I get to that point. I would like to throw a System::ApplicationException from the unmanaged code, is there any problems with this? I am formating a string in one of these throws where I am using String::Format and one of the values is a unmanaged enum (ie int). How do I go about boxing it to use it in the String::Format call? When I try to...
2
12354
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the classes in managed C++ as a wrapper to the unmanaged C++ classes or is there an easier way? Essentially what I have done is written a C++ kernel mode driver and I want to use it from my C# program. Because it requires some setup outside the...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.