安全异常 - mscorlib,检索具有CLSID的COM类组件失败

时间:2013-02-11 14:11:42

标签: web-services security exception mscorlib

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

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);
    }

我有web配置

<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()

如果有人需要更多关于它的信息,请告诉我。

1 个答案:

答案 0 :(得分:3)

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

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

这是一个链接希望这有助于一些:http://msdn.microsoft.com/en-us/library/1sfbfyk0.aspx