2010-03-04 59 views
0

任何人都可以告訴我什麼是錯誤的基於以下異常我的web應用程序?當我嘗試從VS2008運行此項目時遇到此問題:mscorlib異常

System.Security.SecurityException was unhandled 
    Message="Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." 
    Source="mscorlib" 
    StackTrace: 
     at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) 
     at System.Security.CodeAccessPermission.Demand() 
     at MS.Internal.PresentationFramework.SecurityHelper.DemandUnmanagedCode() 
     at System.Windows.Window..ctor() 
     at System.Windows.Application.GetAppWindow() 
     at System.Windows.Application.ConfigAppWindowAndRootElement(Object root, Uri uri) 
     at System.Windows.Application.DoStartup() 
     at System.Windows.Application.<.ctor>b__0(Object unused) 
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
     at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
     at System.Windows.Threading.DispatcherOperation.InvokeImpl() 
     at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(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.Windows.Threading.DispatcherOperation.Invoke() 
     at System.Windows.Threading.Dispatcher.ProcessQueue() 
     at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
     at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
     at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) 
     at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) 
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
     at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
     at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
     at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
     at System.Windows.Threading.Dispatcher.Run() 
     at System.Windows.Application.RunDispatcher(Object ignore) 
     at System.Windows.Application.RunInternal(Window window) 
     at System.Windows.Application.Run(Window window) 
     at System.Windows.Application.Run() 
     at XamlGeneratedNamespace.GeneratedApplication.Main() 
     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() 
    InnerException: 

請參閱我的更新的評論。 剛剛添加了一個編輯。

+0

你可以顯示異常時運行的線程的代碼嗎?我可以看到一些窗口正在顯示/調用這是一個WPF是否正確?由於某種原因,該窗口觸發了權限異常...還有該窗口的代碼以及請... – t0mm13b 2010-03-04 16:57:49

+0

如何在異常時運行代碼?我看到的是: 步驟爲:跨過非用戶代碼「XamlGeneratedNamespace.GeneratedApplication.InitializeComponent」 步驟爲:步進比非用戶代碼 「XamlGeneratedNamespace.GeneratedApplication.GeneratedApplication」 步驟爲:步進比非用戶代碼 「XamlGeneratedNamespace.GeneratedApplication.InitializeComponent」 步驟爲:步進比非用戶代碼 「XamlGeneratedNamespace.GeneratedApplication.GeneratedApplication」 步驟爲:步進比非用戶code'XamlGeneratedNamespace.GeneratedApplication.InitializeComponent」 – salvationishere 2010-03-04 19:07:48

+0

我很驚訝,這是在正常的Web應用程序的xaml附近。你確定這不是一個WPF/Silverlight應用程序嗎? – 2010-03-04 21:39:14

回答

0

查看是否有執行非託管代碼權限...如果沒有,授予它,然後再試一次...

我認爲這是要在您的規則arsed了對一些設置原因...

Martin。

+0

我該怎麼做?我發現一個鏈接描述如何使用以下代碼執行此操作,但我正在尋找更簡單的解決方案: http://msdn.microsoft.com/en-us/library/d0313z05.aspx – salvationishere 2010-03-04 19:00:37

+0

開始>控制面板>管理工具> Microsoft .Net Framework配置。 看看執行策略 - 似乎有一個「運行非託管代碼」部分 - 不知道如何編輯它 - 只是嘗試和失敗自己... – 2010-03-04 21:38:00

+0

謝謝你的迴應!我在運行時安全策略的權限集下的多個位置找到了「執行」選項卡。但所有這些都是隻讀的。對於所有這些都設置爲「否」。如何編輯權限集? – salvationishere 2010-03-04 21:50:08

相關問題