Click here to Skip to main content
15,034,353 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I took sample codes from "Calling All Stations[^]"
to build my own CPP DLL and C# application. The application and DLL were built successfully. I used tools, sigcheck, dumpbin /headers, to confirm the application and DLL are both 32-bit ones.
Unfortunately, the error (HRESULT: 0x8007000B) occurred while DLL being called by the application.
I checked almost every aspect to confirm that both ones are 32-bit. I wonder what I can do to check the miss to figure out the trouble. What can I do to work it out?
My IDE is Visual Studio 2019.

What I have tried:

I googled lots of articles talking about 0x8007000B and used tools; such as sigcheck, dumpbin /headers to check it and found no cause.
Posted
Updated 1-Feb-21 5:40am
Comments
Shao Voon Wong 1-Feb-21 4:55am
   
Make sure the dll is inside the executable directory and the calling conventions are the same.
Stan Huang 1-Feb-21 5:04am
   
Yes, I did check the folder of DLL and application is the same. Calling-convention is assured too.
Shao Voon Wong 1-Feb-21 5:22am
   
Did you try to return a char* as string to C#?
Stan Huang 1-Feb-21 5:43am
   
I failed at the first calling. It's an 'int' return type function without any parameter. So, I think there is no issue as you said.
Richard MacCutchan 1-Feb-21 5:17am
   
I just built these projects in VS2019 with no changes, and it works fine. Could you find out exactly where the error occurs and let us know?
Stan Huang 1-Feb-21 5:47am
   
I built and ran that sample successfully too. But what I furtherly did is updating my DLL to my own DLL and calling it from my own application program. I followed the same DLL structure of the sample DLL codes and followed the same calling method as the sample application. I believe the same code structure in my DLL and application as the sample program. I just don't know why I got such error return 0x8007000B.
Shao Voon Wong 1-Feb-21 6:05am
   
The application in that article is a winform. Is yours a winform or commandline app? Does your C function call COM functions?
Stan Huang 1-Feb-21 6:16am
   
My application is in C# and GUI program, running well before. I updated its codes calling DLL portion by referring C# calling portion at the sample program. Similarly, I created my own DLL by modifying CPPDLL of the sample program. My application is GUI, not command line.
Shao Voon Wong 1-Feb-21 6:25am
   
You can take a look at

https://stackoverflow.com/questions/18007967/net-framework-error-hresult-0x8007000b
Stan Huang 1-Feb-21 21:29pm
   
It doesn't help because the situation, Windows version and VS version are far different from mine. Also, I don't find the real solution.
Richard MacCutchan 1-Feb-21 6:58am
   
Something that you changed must have been incorrect.

1 solution

Check that the C# app and its components are also 32 bit executables. Sounds like you have this issue: .net Framework Error (HRESULT 0x8007000B).
   
Comments
Stan Huang 2-Feb-21 6:03am
   
That issue is different from mine, just similar. They don't really propose a solution.
Shao Voon Wong 3-Feb-21 2:09am
   
Write a simple project to reproduce the problem and upload it to GitHub and I'll take a look.
Stan Huang 3-Feb-21 6:40am
   
I'm considering building both (C# application / C++ DLL) in 64-bit. I built the 64-bit application successfully. But I failed to do it for DLL. I changed its property page's Target Machine option to x64, then re-built it. I got the error: "fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'"
How come? What should I do to build a 64-bit DLL?
Shao Voon Wong 4-Feb-21 1:44am
   
Your C++ DLL project probably does not have x64 profile. Open the Configuration Manager to create one.

https://imagizer.imageshack.com/img924/5964/dfmqgh.png

You have to figure out how to use the configuration manager. Teaching you would take me many screenshots. Configuration manager can also show if your C# application is AnyCPU or true 32-bit. Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900