Search code examples
webpinvokesilverlight-5.0

Running Silverlight 5 RC P/Invoke application in a browser from internet?


Is it possible to run Silverlight 5 RC application that is using P/Invoke to access Win API functions while the application is run in web browser? The source of the application is from web site on internet.

I am asking this because I have no luck. I am experiencing Error: Unhandled Error in Silverlight Application Attempt by security transparent method 'xxxx' to call native code through method 'yyyyy' failed. Methods must be security critical or security-safe-crictical to call native code.

I tried adding [SecurityCritical] attribute on the method calling the P/Invoke method but with no success. Then I tried to put it to the entire calling class but again with no luck.

Does anybody has a solution for this?

Is it possible to do that ? Is it a problem because of the partial trust of applications from internet ?


Solution

  • To use P/Invoke, your SL application must be a full-trust application.

    You can run trusted application from a browser, but it requires some setup by an admin.