Groups | Blog | Home
all groups > visual c > december 2006 >

visual c : Attempted to read or write protected memory. Exception in release build, instantiating unmanaged class.


Bruce
12/30/2006 11:36:06 PM

I am getting the following exception in the release build of my assembly.

{"Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."} System.Exception
{System.AccessViolationException}

I do not have any problems in debug. The problem occurs while
instantiating an unmanaged class.

Any idea what is causing the problem? Why would I get the problem in
release but not debug?


I have included the wrapper managed class below. The unmanaged class
GarXface4::UsbDeviceNameList enumerates USB devices using functions
found in Setupapi. The class works fine when called with unmanaged code.


public ref class UsbNames
{
public:
UsbNames()
{
m_pLst = new GarXface4::UsbDeviceNameList();
}

~UsbNames()
{

delete m_pLst;
}

private:

GarXface4::UsbDeviceNameList *m_pLst;
};


--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
Bruce
12/31/2006 12:02:24 AM
Never mind, I got this working. Just needed to recompile the unmanaged
class's static lib.




--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
AddThis Social Bookmark Button