Application Trust Level on Network Drive for Nhibernate C# Application
-
08-10-2019 - |
Question
Scenario: I have a C# application that uses Click-Once to install(puts an icon on the desktop that points to the application) itself on computers on the network. I have recently been integrating NHibernate into the program and everything runs smooth on my box. Its ready for internal testing and I need to put it on our network share (Same share as production, different folder).
Problem: When I place it on the network share and run it I recieve an error saying the application cannot run in partial trust.
Question: I have googled this to no end and every solution seems to talk about a Web Application experiencing this. Is there anyway I can set the application to run in full trust mode on a network share. Setting the folder/exe to full trust? Is this simply allowing "Full Control" in the security tab of my applications properties?
Here is the error I recieve when running the application
Thanks for any input
Solution
You need to set the security policy on the client machine using CasPol.exe or the configuration tool in Administrative Tools.
- Code Access Security Policy Tool
- Using CasPol to Fully Trust a Share
- .NET Framework Configuration Tool (Mscorcfg.msc)
- Code Access Security Policy (CASPOL.exe) GUI Utility
Alternatively, you can upgrade to .net 4.0, which gets rid of all this.
EDIT: You can also try adding [assembly: AllowPartiallyTrustedCallers]
to the referenced assembly.
OTHER TIPS
Putting an Icon on the desktop that points to a network share does not sound like Click-once.
But this 'problem' should be solved from Fx 3.5 SP1 onwards.