In Silverlight applications, sometimes you want to call unmanaged libraries or native code, including Microsoft Win32 functions. In Silverlight 5, you can call unmanaged or native code through the platform invoke feature. Platform invoke is also referred to as PInvoke or P/Invoke. Platform invoke in Silverlight is very similar to platform invoke in the .NET Framework. However, there are some important differences.
Platform invoke in Silverlight can only be used in trusted applications hosted either in-browser or out-of-browser.
Platform invoke in Silverlight can only be used on computers running the Windows operating system. There is no Mac support.
Can someone share why I would want to adapt Silverlight’s model then bolt myself to the Windows platform using P/Invoke? I can’t imagine many Silverlight developers were clamoring for P/Invoke functionality, as they made the decision to go Silverlight based on its operating system agnosticism. The only case fumbling around in my head now is one involving “enhanced experiences”. Perhaps a Silverlight developer would want to detect the OS it’s running on and upgrade itself if it’s on Windows. But that’s far-fetched given the requirements to do so (full trust). So, err… what the heck is the use case here? Why not just use WPF?