Is this a good or bad?
Pinvoke.Net is a great site, and I was wondering whether to be happy or sad. On the bright side, it's great to see a community effort like that, and the site is really useful. On the down side, it's sad that pinvoke would be so complicated that something like that would be necessary.
Now to be fair, it's an interesting question to compare PInvoke's complexity relative to the innate complexity of the problem space. Bridging between the world of C++ (with its pointers, anonymous tagged unions, highly-platforms specific structures, unsafe strings, etc) and C# seems challenging. Unfortunately, I don't really have the domain knowledge to make much commentary there.
Comments
- Anonymous
March 11, 2006
I don't think pinvoke is difficult, but I can see how it is very non-obvious to people coming from VB6 or people that have never written any unmanaged code. There are probably more of these developers out there than you realize. For them, pinvoke.net is a godsend. - Anonymous
March 11, 2006
I find it unfortunate that big chunks of PInvoke.net's declarations are actually already embedded in the .NET framwork - but they've been declared internal so no one else gets to take advantage of them. That forces a lot of wasteful duplication.
I also wonder why MS didn't provide a lot of the PInvoke.net content themselves (they did something along those lines way back in VB6!). A central respository with VS integration would have been a great resource for MS to provide. Or, alternatively, a Microsoft.Win32.Declarations assembly that could be periodically updated as new declarations are added. - Anonymous
March 12, 2006
I don't think the problem is that pinvoke is difficult but that remembering the signatures for all the different methods is difficult (not to mention a pointless waste of brain power). It's the same reason we have intellisense.
Incidentally, there is / was an add in for integrating the pinvoke site within VS.NET 2003: http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=75122f62-5459-4364-b9ba-7b5e6a4754fe. Not sure if it's been updated for VS 2005. - Anonymous
March 13, 2006
I personally find that Pinvoke can get difficult on more complex signatures; especially when:
- you need to start marshalling complex C-style structures.
- the signature really breaks type-safety (eg, passes back an int that's sometimes a string).