Microsoft .NET pros and cons :  Phorum 5 The fastest message board... ever.
This is for discussion about the benefits of .NET vs Win32 or other programming platforms such as Java. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
For: Easy platform invoke
Posted by: Tim (
Date: Wednesday, 22-Sep-2004, 21:41:45

It's pretty easy to call native code DLLs or COM objects from .NET; easier than in Java where you need to compile an intermediate JNI library. Of course PInvoke has a cost in terms of portability and security, but it can be exceptionally useful, making the difference between success and failure of a .NET project.

Re: For: Easy platform invoke
Posted by: Atmapuri (
Date: Friday, 24-Sep-2004, 06:59:35


Now that is something that should carry an "against" flag. That
claim is far from true. The presence of the garbage collector
complicates things when passing unmanaged memory
to managed code and back in to great lengths.

The presence of the garbage collector (which may or may not)
move the memory while the unmanaged code is executing
makes bug tracing "the highest art" and leaves any troubles
that were present in W32 world in the dust far behind.

Under W32 there was no need for memory pin down
or a need to copy a block of memory before passing
it to a dll. (Which is also not completely cheap CPU wise).

Similar is true for unsafe code. You might have an app
working fine and dying for no reason every 2 days,
because of such a bug.


Re: For: Easy platform invoke
Posted by: Tim (
Date: Friday, 24-Sep-2004, 07:27:46

Good points; but I didn't intend to argue that .NET platform invoke is easier than calling native DLLs from unmanaged code such as C, C++ or Delphi (Win32). I am really comparing .NET and Java here. Surprisingly, .NET also has some advantages over VB 6 when calling the API, but that's more a comment on how difficult VB made it.

.NET does at least have mechanisms to deal with the issues you mention. In addition, pinning memory and so on is not necessary for the majority of calls to unmanaged code, but only in certain cases.


Re: For: Easy platform invoke
Posted by: JonSkeet (
Date: Monday, 27-Sep-2004, 11:18:46

I think the important thing is to "know your limitations". I don't know much about interop, but I know what I don't know, if you see what I mean. I know when I'm getting out of my depth, and go for expert help in that situation.

In the common case where you *don't* need pinning etc, the interop facilities provided by .NET are great.

C# MVP with plenty of Java experience.
No particular ties with MS aside from MVP-ness, but I think they're doing the right thing (in general) with .NET.

Your Name: 
Your Email: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.