Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / March 2004

Tip: Looking for answers? Try searching our database.

Unmanaged C++ Dll, CallingConvention.ThisCall

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claudia Mitsch - 12 Mar 2004 10:06 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.