启动使用 ClickOnce 部署的 wpf 应用程序时出错
Error on launching wpf application which is deployed using ClickOnce
我正在为我的 wpf 应用程序使用 Prism.Unity Template Pack。当我 运行 visual studio 中的代码时,一切正常。但是在部署之后,应用程序启动时会抛出错误。尝试环顾四周,但无法理解如何修复验证异常。
由于 Prism 在库中集成了 Unity,因此我无法调试它。我还查看了 github 的源代码,但没有找到任何线索。
事件日志:
Application: applaunch.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Security.VerificationException
at Unity.Storage.Registrations..ctor(Int32)
at Unity.UnityContainer..ctor()
at Prism.Unity.PrismApplication.CreateContainerExtension()
at Prism.PrismApplicationBase.Initialize()
at Prism.PrismApplicationBase.InitializeInternal()
at System.Windows.Application.<.ctor>b__1_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at PrismUploadUI.App.Main()
at System.AppDomain._nExecuteAssembly(System.Reflection.RuntimeAssembly, System.String[])
at System.Runtime.Hosting.ManifestRunner.NewThreadRunner()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
如果有人遇到这个问题,我已经解决了它,它与 prism 模板无关,也与 prism unity 无关,这是由于 .csproj 文件中的几个标签导致了这个问题。
删除 <TargetZone>LocalIntranet</TargetZone>
解决了我的问题,但我仍然不明白为什么即使我在应用程序属性中将其设置为 完全信任 该项目。还有一件事是我确实将清单设置设置为没有清单的创建应用程序,但我在 csproj 中发现此标记为 <GenerateManifests>true</GenerateManifests>
。我当时弄错了。
所以大家也要检查 csproj 文件中添加的内容。
我正在为我的 wpf 应用程序使用 Prism.Unity Template Pack。当我 运行 visual studio 中的代码时,一切正常。但是在部署之后,应用程序启动时会抛出错误。尝试环顾四周,但无法理解如何修复验证异常。
由于 Prism 在库中集成了 Unity,因此我无法调试它。我还查看了 github 的源代码,但没有找到任何线索。
事件日志:
Application: applaunch.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Security.VerificationException at Unity.Storage.Registrations..ctor(Int32) at Unity.UnityContainer..ctor() at Prism.Unity.PrismApplication.CreateContainerExtension() at Prism.PrismApplicationBase.Initialize() at Prism.PrismApplicationBase.InitializeInternal() at System.Windows.Application.<.ctor>b__1_0(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at PrismUploadUI.App.Main() at System.AppDomain._nExecuteAssembly(System.Reflection.RuntimeAssembly, System.String[]) at System.Runtime.Hosting.ManifestRunner.NewThreadRunner() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()
如果有人遇到这个问题,我已经解决了它,它与 prism 模板无关,也与 prism unity 无关,这是由于 .csproj 文件中的几个标签导致了这个问题。
删除 <TargetZone>LocalIntranet</TargetZone>
解决了我的问题,但我仍然不明白为什么即使我在应用程序属性中将其设置为 完全信任 该项目。还有一件事是我确实将清单设置设置为没有清单的创建应用程序,但我在 csproj 中发现此标记为 <GenerateManifests>true</GenerateManifests>
。我当时弄错了。
所以大家也要检查 csproj 文件中添加的内容。