Silverlight 4.0 FileStream

FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); 

Arguments: <path → String debugging resource is not available. Often the key and arguments provide enough information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.41108.0&File=mscorlib.dll&Key=FileSecurityState_OperationNotPermitted

There is an error in the above line of code [FileSecurityState_OperationNotPermited]

+4
source share
1 answer

It looks like your application is running in partial trust. To use FileStream, you need to request increased trust :

By default, Silverlight applications run in partial trust, which means that they run as part of the sandbox security. Sandboxes have limited access to local computers and are limited in other ways to prevent malicious behavior.

From the Silverlight 4 FileStream documentation (highlighted by me):

When it is invoked by an elevated trust application , it provides a stream around a file that supports synchronous and asynchronous read and write operations.

EDIT: You can set the application to require increased trust by setting the option "Require increased trust when working outside the browser" in the Silverlight project settings.

+4
source

Source: https://habr.com/ru/post/1303522/


All Articles