K
Karthik V
In a certain dll, there is this function:
typedef DWORD STDAPICALLTYPE SOMEFUNC(VOID *pHandle, IProgress
*pProgress);
where IProgress is
class IProgress { public: virtual void Update(UINT progress) = 0; };
To pinvoke this from C#, I tried the following:
[DllImport("THE_DLL.dll", SetLastError = true)]
static extern void SomeFunc(IntPtr handle, Progress progress);
and defined Progress as
public class Progress
{
public void Update(ushort progress)
{
// some code
}
}
Trying to invoke SomeFunc and passing an object of Progress, I get an
"Attempted to read or write protected memory" error. The other methods
in the same dll that don't involve the progress callback object (but
involve the handle parameter) work fine.
Please let me know how to pinvoke this function.
typedef DWORD STDAPICALLTYPE SOMEFUNC(VOID *pHandle, IProgress
*pProgress);
where IProgress is
class IProgress { public: virtual void Update(UINT progress) = 0; };
To pinvoke this from C#, I tried the following:
[DllImport("THE_DLL.dll", SetLastError = true)]
static extern void SomeFunc(IntPtr handle, Progress progress);
and defined Progress as
public class Progress
{
public void Update(ushort progress)
{
// some code
}
}
Trying to invoke SomeFunc and passing an object of Progress, I get an
"Attempted to read or write protected memory" error. The other methods
in the same dll that don't involve the progress callback object (but
involve the handle parameter) work fine.
Please let me know how to pinvoke this function.