I have now tested to build and run csipopt on Silverlight 5 RC, and it almost works:
- The code successfully builds, provided the
<AllowUnsafeBlocks>tag is manually set to true in the .csproj file.
- If I bundle the native IPOPT DLL:s as content or resources in the XAP file, I get a
DllNotFoundException. At this point I do not know if this is a bug or by design. For now, it works to place the native IPOPT DLL:s in a directory that is included in the system path.
- When I run my csipopt calling application in OOB elevated-trust mode, I eventually get a
SecurityException: An error relating to security occurred.
UnmanagedFunctionPointerAttributein a call to an imported function from the native DLL. It remains to find out whether this restriction will persist into the final release of Silverlight 5. According to the API documentation, the
UnmanagedFunctionPointerAttributeis not intended for regular user code in Silverlight. This writing might not be entirely up-to-date, but realistically, I think the restriction will be there at least in Silverlight 5. After all, I am pushing the limits here, using P/Invoke and unsafe code at the same time.
So, bets are I have to wait for Silverlight 6 to employ csipopt in my Silverlight applications.