C
Chandrashekhar C
Guest
Our application is calling a VC++ 6.0 (MFC Automation server) dll from a sample VB.Net (VS 2017 frame work 4.7.2), while calling a method from .Net it is throwing the below error message.
The same functionality is working fine from VB6 application, it is happening only when calling from a .Net 4.7.2 executable.
'System.AccessViolationException' in mscorlib.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
VB.Net code
Dim obj As New MFCDLL.MFCclass
Dim obj1 As object
obj1 = obj.GetNextMethodRef()
VC++ 6.0 MFCDLL (MFC/ATL automation server) code
LPDISPATCH MFCClass::GetNextMethodRef
{
//returns an IDispatch pointer to the Class Object
//
try
{
return ClassMethod1()->GetIDispatch(TRUE); “Access Violation Error is thrown here”
}
Catch (ErrorClass* pe)
{
Exception;
}
Declaration of m_PointertoMFCClass2
MFCClass2* m_PointertoMFCClass2;
MFCClass2* MFCClass:: ClassMethod1()
{
//returns a pointer to the portfolio object
//
try
{
return m_PointertoMFCClass2;
}
Catch (ErrorClass * pe)
{
Exception;
}
Whereas other methods and functions of this DLL which are not using GetIDispatch methods are working fine.
Please let us know if any limitation is there of using VC ++ 6 (MFC) dll with .Net. Also, do let us know resolution of this issue.
Continue reading...
The same functionality is working fine from VB6 application, it is happening only when calling from a .Net 4.7.2 executable.
'System.AccessViolationException' in mscorlib.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
VB.Net code
Dim obj As New MFCDLL.MFCclass
Dim obj1 As object
obj1 = obj.GetNextMethodRef()
VC++ 6.0 MFCDLL (MFC/ATL automation server) code
LPDISPATCH MFCClass::GetNextMethodRef
{
//returns an IDispatch pointer to the Class Object
//
try
{
return ClassMethod1()->GetIDispatch(TRUE); “Access Violation Error is thrown here”
}
Catch (ErrorClass* pe)
{
Exception;
}
Declaration of m_PointertoMFCClass2
MFCClass2* m_PointertoMFCClass2;
MFCClass2* MFCClass:: ClassMethod1()
{
//returns a pointer to the portfolio object
//
try
{
return m_PointertoMFCClass2;
}
Catch (ErrorClass * pe)
{
Exception;
}
Whereas other methods and functions of this DLL which are not using GetIDispatch methods are working fine.
Please let us know if any limitation is there of using VC ++ 6 (MFC) dll with .Net. Also, do let us know resolution of this issue.
Continue reading...