为什么我的.NET应用程序需要完全信任?

编程入门 行业动态 更新时间:2024-10-26 06:27:00
本文介绍了为什么我的.NET应用程序需要完全信任?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I've developed a 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" 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应用程序需要完全信任?

本文发布于:2023-11-05 08:42:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560391.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!