When you write Winforms or WPF applications, how many times that you find the built in managed APIs doesn't meet your needs, and you have to write the
so evil so bizzare, and so unnatural interop code to get some sorta functionality you are dreaming of, that's really annoying indeed, especially for a guy like me who never have any experience with unmanaged code, why doesn't Microsoft
build a well rounded and fully functional managed wrapper APIs on top of the WIN32 APIs, so we can work with the more familiar, more natural, and easier to understand APIs rather than digging into some sorta of WM, IntPtr or some other alien constructs:(?
HERE! HERE! HERE! I second this. Yes, I know someone (or more? :>) is going to talk about the technical difficulties of this, or timing, etc, but the reality is, the only people who coud possibily understand the interop things are C++ or assembly coders.
VB and java devs aren't in tune with that kind of stuff. It's just not natural.
Oops, no one is interested in this topic, uh?
The problem is that the Win32 API is immense, and has evolved over more than a decade. It has many inconsistencies and pitfalls when wrapping it in managed code (which, I agree, is precisely why interop can be so hard).
If you're doing a "wrapper to end all wrappers", you'd have to decide how to deal with each of these cases, and whether or not you're going to try to make things consistent (and thus easier on the managed code writer; this was done for instance with Managed
DirectX, they decided to use a model that may be less natural to someone with experience with DX in C++, but more natural for someone who knows .Net but not DX) or keep the inconsistencies of Win32 so there's a better 1-to-1 mapping.
In any case, the amount of work would be enormous.
And it still wouldn't really end all interop; you'd still need it when interacting with a third party library.
I agree, interop is a pain in the butt. I hope that as .NET matures, we'll see more and more of the bits that currently require interop to be properly managed.
I think it would be worse if we had everything wrapped badly than not having it wrapped at all though.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.