为什么我的.NET应用程序需要完全信任? [英] Why does my .net application require full trust?

查看:96
本文介绍了为什么我的.NET应用程序需要完全信任?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了.NET 3.0的应用程序,这是使用ClickOnce部署。

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.

我试着下的Visual Studio我的项目的安全性选项卡中的计算权限工具,答案是很清楚的:

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.

不过,我已经无法弄清楚为什么完全信任是必要的。我试图更改安全设置部分信任,但应用一经推出,立即引发一个SecurityException:

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 executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

我的软件可能并不需要完全信任(我只使用https连接到Web服务器,并访问文件系统只在用户请求时,对进口/出口目的)

My software probably doesn't need full trust (I only connect to a webserver using https, and access the filesystem only upon user request, for importation/exportation purposes)

我怎么能弄清楚,为什么我的应用程序需要完全信任?

How can I figure out why my application requires full trust?

推荐答案

添加requirePermission =在App.config的configsections'假'的属性有很大帮助:

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 !

这篇关于为什么我的.NET应用程序需要完全信任?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆