i have a very small utilty app written in c# that works fine on my local machine but if i put it on a network drive and try to run it from there i get the following securityException..
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Anyone know why and how i can fix it?
Thanks!
This is default behaviour for earlier .NET versions. It was 'fixed' in 3.5 SP1. Here is a link.
If you need to use an earlier version, the only solution is to adjust the trustlevel of the assembly (on each PC that uses it). Usually no fun.
Related
On this line I get the following exception:
using (Stream reader = File.Open(m_inputFile, FileMode.Open))
Exception:
The message is: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
This happens in an Excel addin running in ExcelDNA, however this fails as soon as the XLL for Excel is put on a network drive.
How can I allow full permissions to read from local drives as I am on a secure network ?
This is probably due to the default security settings under .NET 2.0, which grant restricted permissions to code running over a network.
The first step is the ensure that you are running a recent version of Excel-DNA - there were some changes related to the security of the AppDomain setup a few years ago that might be relevant.
Another fix you can try is to retarget your add-in to .NET 4.0. You probably don't even have to recompile, just change your .dna file to start with:
<DnaLibrary RuntimeVersion="v4.0" Name="..." >
If you want to stick with the .NET 2.0 runtime, you can change the permissions by using the caspol utility. There are some detailed instructions in this post on the Google group: https://groups.google.com/d/msg/exceldna/Csls-_bjDp0/G3HlxFkDefQJ
The following exception is raised when opening a WCF client from a .NET 4 desktop application. This only seems to be happening at one of our client installations:
Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
Does anyone know how to resolve this?
Interestingly here's another (unanswered) SO from someone getting the same problem from CruiseControl: .Net 4 CAS - Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Action: Demand. It's possible that this'll end up being a dupe; but that's unfair at the moment since that's not been answered.
This seems similar to the pre 3.5 sp1 network security woes, where applications runs from a network location would be denied many permissions through CAS.
I think this blog post might provide the solution, although it might not apply if the executable itself is loaded from a remote location (check the first solution) http://www.damirscorner.com/CodeAccessSecurityStrikesBackInNET4.aspx
Although, also looking at Exploring the .Net Framework 4 Security Model (which provides the same workarounds as the aforementioned blog post) it might not apply, as it implies that unhosted Exes run from network locations should run fully-trusted by default - when clearly yours aren't!
One thing to try if this doesn't work is to make the exe (and by extension all it's references) strong-named.
Having read Andras's answer and checked some other applications we provide to clients, it seems the following code in the app.config file could sort the issue (as it's present in our other applications but not the one we're having an issue with):
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
Good day. I have developed an application which works successfully on my local machine but I have run into a problem when moving out to production.
The error is as follows:
System.IO.FileNotFoundException: Could not load file or assembly 'IBM.XMS.Admin, Version=2.5.0.0, Culture=neutral, PublicKeyToken=d2666ab12fca862b' or one of its dependencies. The system cannot find the file specified.
File name: 'IBM.XMS.Admin, Version=2.5.0.0, Culture=neutral, PublicKeyToken=d2666ab12fca862b'
I understand where this file is - C:\Prog... - and my .Net application is simply referencing IBM.XMS.dll which works. It's when I deploy and run I get the error above.
I used the following installation instructions and restarted the system too:
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzav.doc/un10290_.htm
Your application is built with XMS v2.5. Do you have XMS v2.5 (shipped with MQ v7.5 client) installed on the other machine?
check out Microsoft's fusion log viewer and see how you get on.
In my experience when I see this message the keywords are or one of its dependencies. The fusion log may help you find out which one.
I have a WPF web app and I"m trying to access a SQL 2000 database, but I'm getting the following error:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Any idea how I can fix this? I probably need an example as I'm new to this and this is my first WPF application.
Try switching to full trust application.
Your application lacks the necessary permissions to connect to the SQL database. Try running it as an administrator (it may be easiest to simply launch Visual Studio as admin).
Full trust + Enable ClickOnce Security Settings make code conect server again.
Curious this PublicKeyToken=b77a5c561934e089', I thoug was the signing my applications, seems MS uses for a generic security setting
I am having trouble with security while migrating an application from .NET 3.5 to 4.0.
I have an application that starts successfully from a network share I've mapped to z: - Z:\MyApp\App.exe.
This application makes use of add-ins, and is sometimes asked to load assemblies from a seperate location on the Intranet - y:\MyLib\Lib.dll
In .NET 4.0, I get a System.Security.Security exception then this happens:
System.IO.FileLoadException: Could not load file or assembly 'XXXX' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A) ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
However, if I launch my application locally from C:\MyApp\App.exe, it is able to successfully load with Assembly.LoadFrom() the addin at y:\MyLib\Lib.dll.
What do I need to do to 'bless' the y:\MyLib location so that apps running from network shares are allowed to execute code from there?
Thanks,
Dave
I had a similar problem, I was able to solve it as is described in my question
Structuremap does not load registries when started from Network drive.
I hope this solves your problem also.