Alex Rivera | Logout

Why does my .net application require full trust?

Asked 2009-02-17T16:56:26.360
13

I've developed a .net 3.0 application, which is deployed using clickonce.

I'd like to move from full trust to partial trust to ease deployment.

I've tried the "Calculate Permissions" tool in the "Security" tab of my project under visual studio, and the answer is quite clear :

---------------------------
Microsoft Visual Studio
---------------------------
This application requires full trust to run correctly.

However, I've not been able to figure out why full trust is required. I've tried to change the security settings to "partial trust", but the application raises a SecurityException immediately upon launch :

System.Security.SecurityException   {"Request failed.", Action= "System.Security.Permissions.SecurityAction.LinkDemand"
   at MyNameSpace.Program.Main(String[] args)
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
   at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
   at System.Activator.CreateInstance(ActivationContext activationContext)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext e
Edit
Report

2 Answers

2

Adding the requirePermission='false' attribute in the app.config's configsections helps a lot :

 <sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section requirePermission="false" name="defaultProxy" type="System.Net.Configuration.DefaultProxySection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </sectionGroup>

It made the trick for me !

answered 2009-02-18T09:37:24.957
0

Hrm, just a guess, but is it running off of a network share? .NET seems to assign trust based on the location the code is being run from. If it's from anywhere but your local hard drive then you're going to have security issues.

answered 2009-02-17T16:58:47.323

Your Answer