1

我在初始化应用程序的这个阶段遇到了麻烦。

public static void Initialise()
    {
        Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //throwing exception here
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    }

我有网络配置在哪里

<trust level="full"/>

消息是:

Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

堆栈跟踪如下:

at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Windows.Forms.Application.add_ThreadException(ThreadExceptionEventHandler value)
at Chronos.Shared.ErrorHandler.Initialise()
at Chronos.TeamLeader.Program.Main()
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

让我知道是否有人需要有关它的更多信息。

4

1 回答 1

3

我在通过这个安全异常时遇到了很多困难。阅读大量博客,参与讨论,但没有任何结果。

最后在 msdn 中找到了“启用 ClickOnce 安全设置”。我只是按照这些步骤并禁用了项目属性中的安全设置。

这是一个链接,希望对您有所帮助:http: //msdn.microsoft.com/en-us/library/1sfbfyk0.aspx

于 2013-02-13T14:07:05.583 回答