Hi all!
I am trying to use an unmanaged Dll in C# CF. Most of it is object oriented, and - as constructors can't be invoked with dllimport - I added TestClass* CreateTestClass() and DeleteTestClass(TestClass* obj) functions and used IntPtr in C# to hold the instance.
In .NET Framework, it is possible to call all class methods by passing this IntPtr as first parameter if CallingConvention.ThisCall is specified. This property is not available in CF, does anyone know a workaround? Or will the only solution be to make changes to the DLL?
Any ideas or suggestions are welcome!
Thanks,
claudia
Chris Tacke, eMVP - 12 Mar 2004 12:07 GMT
You must change the DLL or write another class factory DLL that accepts the
pointer in all methods.
-Chris
> Hi all!
>
> I am trying to use an unmanaged Dll in C# CF. Most of it is object oriented, and - as constructors can't be invoked with dllimport - I added
TestClass* CreateTestClass() and DeleteTestClass(TestClass* obj) functions
and used IntPtr in C# to hold the instance.
> In .NET Framework, it is possible to call all class methods by passing this IntPtr as first parameter if CallingConvention.ThisCall is specified.
This property is not available in CF, does anyone know a workaround? Or will
the only solution be to make changes to the DLL?
> Any ideas or suggestions are welcome!
>
> Thanks,
> claudia
Paul G. Tobey [eMVP] - 12 Mar 2004 15:11 GMT
You're going to be *much* better off to build a suitable C-style interface
to the DLL in unmanaged code, where you have control over everything, than
to try to fake the 'this' pointer in object calls to everything.
Paul T.
> Hi all!
>
> I am trying to use an unmanaged Dll in C# CF. Most of it is object oriented, and - as constructors can't be invoked with dllimport - I added
TestClass* CreateTestClass() and DeleteTestClass(TestClass* obj) functions
and used IntPtr in C# to hold the instance.
> In .NET Framework, it is possible to call all class methods by passing this IntPtr as first parameter if CallingConvention.ThisCall is specified.
This property is not available in CF, does anyone know a workaround? Or will
the only solution be to make changes to the DLL?
> Any ideas or suggestions are welcome!
>
> Thanks,
> claudia
Claudia Mitsch - 15 Mar 2004 09:51 GMT
Thanks both of you, I already considered the two options. Just wanted to make sure not to overlook the "best practice" for this case :)
sincerely
claudia