Shot in the dark but I thought I'd try to post in hopes of some genius out there...
Background: I am trying to added automated unit testing to a huge unmanaged C++ project. For various reasons within our group, we want to use MSTest. As a result, classes and functions from an unmanged MFC C++ project need to be called from a managed C# project.
Proof of Feasability: I have accomplished this on a small scale to prove that it does, in fact, work. This is what I did:
This works. I can share the example project if you want to see it. The next step was taking the concept and getting to work with our gigantic, highly coupled codebase.
Where I'm at now: Long story short, I have the WRAPPER project building successfully and creating a DLL. I add a reference to my C_SHARP project. I try to run it but it stops immediately with the message:
An unhandled exception of type 'System.IO.FileNotFoundException' occured in mscorlib.dll
Additional information: Coule not load file or assembly 'WRAPPER.dll' or one of its dependencies. The specified module could not be found.
Ran dependency walker in profile mode and got this:
Starting profile on 3/6/2012 at 10:45:11 AM
Operating System: Microsoft Windows XP Professional (32-bit), version 5.01.2600 Service Pack 3 Program Executable: c:\example\testing\bin\debug\TESTING.EXE
Program Arguments:
Starting Directory: C:\example\Testing\bin\Debug\
Search Path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Options Selected: Simulate ShellExecute by inserting any App Paths directories into the PATH environment variable.
Log DllMain calls for process attach and process detach messages.
Hook the process to gather more detailed dependency information.
Log LoadLibrary function calls.
Log GetProcAddress function calls.
Log first chance exceptions.
Log debug output messages.
Use full paths when logging file names.
Log a time stamp with each line of log.
Automatically open and profile child processes.
00:00:00.000: Started "c:\example\testing\bin\debug\TESTING.EXE" (process 0xF4) at address 0x00400000. Successfully hooked module.
00:00:00.047: Loaded "c:\windows\system32\NTDLL.DLL" at address 0x7C900000. Successfully hooked module.
00:00:00.140: Loaded "c:\windows\system32\MSCOREE.DLL" at address 0x79000000. Successfully hooked module. 00:00:00.250: Loaded "c:\windows\system32\KERNEL32.DLL" at address 0x7C800000. Successfully hooked module.
00:00:00.250: DllMain(0x7C900000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\NTDLL.DLL" called.
00:00:00.250: DllMain(0x7C900000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\NTDLL.DLL" returned 1 (0x1).
00:00:00.297: DllMain(0x7C800000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\KERNEL32.DLL" called.
00:00:00.312: DllMain(0x7C800000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\KERNEL32.DLL" returned 1 (0x1).
00:00:00.312: Injected "c:\documents and settings\administrator\desktop\depends22_x86\DEPENDS.DLL" at address 0x08370000.
00:00:00.344: DllMain(0x79000000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\system32\MSCOREE.DLL" called.
00:00:00.344: DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\documents and settings\administrator\desktop\depends22_x86\DEPENDS.DLL" called.
00:00:00.344: DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\documents and settings\administrator\desktop\depends22_x86\DEPENDS.DLL" returned 1 (0x1).
00:00:00.344: GetProcAddress(0x7C800000 [c:\windows\system32\KERNEL32.DLL], "FlsAlloc") called from "c:\windows\system32\MSCOREE.DLL" at address 0x79006F3C and returned 0xFFBADD11.
00:00:00.359: Exited "c:\example\testing\bin\debug\TESTING.EXE" (process 0xF4) with code -1073740791 (0xC0000409).
Problem: What is happening? Why does this work in my small feasibility example but not with the actual code I want? I am linking the WRAPPER project to several other libraries but why would that matter?
User contributions licensed under CC BY-SA 3.0