DEP, COM, and C#
I recently worked on an issue where a .NET (C#) application called into a COM component written C++ (7.1) to communicate with the hardware. This code has been in the wild for about 5 years at this point. When we started doing tests with Vista (32-bit) we would get the following:
Exception: Unhandled System Exception Type: System.Runtime.InteropServices.COMException Exception Message: Creating an instance of the COM component with CLSID {E2B8DFBB-***-***-AE5D-57CEF9A2****} from the IClassFactory failed due to the following error: 80010105. Stack Trace: at ***.Scanner.StartScan() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
And this really confused me. I double checked that everything was registered fine, that we had the correct security settings, etc. At one point in this testing, I got a DEP exception and started going down that path. I found that I was unable to disable DEP for .NET programs using the Vista interface.
The Solution:
There is a NXCOMPAT flag that when set to 'YES' will tell Vista to run your code with DEP. Now there is no compiler switch to turn it off (that I found) so what you have to do is change the PE header of the executable. You can most easily do this using the EDITBIN.EXE tool found in "Program Files\Microsoft Visual Studio 8\VC\bin". (You may need the MSPDB80.DLL file from "Program Files\Microsoft Visual Studio 8\Common7\IDE". Run the following command:
editbin.exe /NXCOMPAT:NO myapp.exe
Now let me mention, this is a BAD IDEA. This means that something in your code is allowing code to run from a data page and that really needs to get fixed. But to help the QA process move forward while fixing this issue, this is a quick and simple way to handle it.
Similar Posts
- Improving Your Internet Sales Performance
- Windows Installer Error Codes
- Never Buy Creative Labs Products
