.Net 2005 Managed C++
Background. I am writing a managed c++ wrapper for legacy unmanaged code. I created a test application in C# to create the legacywrapper and I am attempting to get some value returned from legacy.
I am receiving a System.AccessVi olationExceptio n at the end of this function...
Here is the stack trace...
LegacyWrapper.d ll!<Module>.CSt dStr<wchar_t>.{ dtor}() + 0x18 bytes
LegacyWrapper.d ll!<Module>.str ing.{dtor}() + 0x19 bytes
LegacyWrapper.d ll!LegacyWrappe r::LegacyWrap:: GetValue(System ::String^ dataPath = "DB_REG_MANAGER ID:F_RegDTCSize ID:0", System::Object^ pValue = {System::String ^}) Line 884 + 0x9 bytes C++
TestLegacy.exe! TestLegacy.Prog ram.Main(string[] args = {Dimensions:[0]}) Line 17 + 0x12 bytes C#
It looks as if the exception is being thrown when the function is destroying the tmp string...I do not know why...Any suggestions? Thanks in advance...
Background. I am writing a managed c++ wrapper for legacy unmanaged code. I created a test application in C# to create the legacywrapper and I am attempting to get some value returned from legacy.
I am receiving a System.AccessVi olationExceptio n at the end of this function...
Code:
void LegacyWrapper::LegacyWrap::GetValue(String^ dataPath, Object^% pValue) { // This stuff is just used to build up the correct legacy database // to query information based on a the passed in data path. LegacyDatabaseInfo^ dbInfo = gcnew LegacyDatabaseInfo(); GetDbInfo(dataPath, dbInfo); // The Application Controller is simply a entrance into the legacy code ApplicationController* appCntrl = m_legacyCtrl->GetApplicationController(dbInfo->dbID); string tmp; appCntrl->GetValue(dbInfo->fieldID, dbInfo->recordIndex, &tmp); String^ pValueStr = gcnew String(tmp.c_str()); if(pValueStr != nullptr) { pValue = pValueStr; } else { pValue = String::Empty; } // ********************************************** // This is where I get the AccessViolationException // ********************************************** }
LegacyWrapper.d ll!<Module>.CSt dStr<wchar_t>.{ dtor}() + 0x18 bytes
LegacyWrapper.d ll!<Module>.str ing.{dtor}() + 0x19 bytes
LegacyWrapper.d ll!LegacyWrappe r::LegacyWrap:: GetValue(System ::String^ dataPath = "DB_REG_MANAGER ID:F_RegDTCSize ID:0", System::Object^ pValue = {System::String ^}) Line 884 + 0x9 bytes C++
TestLegacy.exe! TestLegacy.Prog ram.Main(string[] args = {Dimensions:[0]}) Line 17 + 0x12 bytes C#
It looks as if the exception is being thrown when the function is destroying the tmp string...I do not know why...Any suggestions? Thanks in advance...
Comment