yon*_*bat 7 deployment wpf clickonce
如何让我的应用程序部署工作?
我使用Visual Studio 2010创建了一个新的简单WPF项目,并在项目的属性中进行了以下修改: - >签名:创建测试证书并将两个程序集都标记为清单.没有选中"仅延迟签名"框 - >安全性:选中框"启用单击一次安全设置"和单选按钮"这是部分信任设置".区域:"本地内联网". - >安全性,高级:使用所选的安全设置调试此应用程序(我选择此项).
开始调试时,我收到类型'System.Security.Permissions.SecurityPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'权限的请求失败.
安装时,将安装应用程序,但启动它时没有任何反应.在另一台计算机上,将显示bla bla已停止工作(启动实用程序).
操作系统:Windows 7.
通过一些实验,我发现将标志UnmanagedCode添加到SecurityPermission解决了这个问题.为什么需要一个简单的WPF应用程序(一个新创建的hello world)来调用非托管代码?这是一个像火山一样大的安全漏洞.
谢谢你的任何提示
聚会迟到了,但这是我发现的(同时偶然发现同样的问题)。
\n\n看来WPFWindow
确实需要UnmanagedCode
许可。
摘自C# 中的 Pro WPF 4.5:.NET 4.5 中的 Windows Presentation FoundationMatthew MacDonald 的
\n\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0
并且,这里是运行在部分信任中通过 ClickOnce 部署的 WPF 应用程序时的异常堆栈跟踪。注意从构造函数DemandUnmanagedCode
调用函数SecurityHelper
Window
:
InnerException: System.Security.SecurityException\n Message=Request for the permission of type \'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\' failed.\n Source=mscorlib\n StackTrace:\n at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)\n at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)\n at System.Security.CodeAccessPermission.Demand()\n at MS.Internal.SecurityHelper.DemandUnmanagedCode()\n at System.Windows.Window..ctor()\n at WPFClickOnceDeploySample.MainWindow..ctor()\n
Run Code Online (Sandbox Code Playgroud)\n\n而且,这是完整的 StackTrace:
\n\nSystem.Reflection.TargetInvocationException was unhandled\n Message=Exception has been thrown by the target of an invocation.\n Source=mscorlib\n StackTrace:\n at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)\n at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)\n at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)\n at System.Activator.CreateInstance(Type type, Boolean nonPublic)\n at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)\n at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)\n at System.Activator.CreateInstance(Type type, Object[] args)\n at CreateInstance(Type type, Object[] arguments)\n at System.Xaml.Schema.SafeReflectionInvoker.CreateInstance(Type type, Object[] arguments)\n at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)\n at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)\n at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)\n at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)\n at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)\n at System.Xaml.XamlWriter.WriteNode(XamlReader reader)\n at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack``1 stack, IStyleConnector styleConnector)\n at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)\n at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)\n at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)\n at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)\n at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)\n at System.Windows.Application.DoStartup()\n at System.Windows.Application.<.ctor>b__1(Object unused)\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\n at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)\n at System.Windows.Threading.DispatcherOperation.InvokeImpl()\n at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)\n at System.Threading.ExecutionContext.runTryCode(Object userData)\n at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\n at System.Windows.Threading.DispatcherOperation.Invoke()\n at System.Windows.Threading.Dispatcher.ProcessQueue()\n at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\n at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\n at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\n at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)\n at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)\n at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\n at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)\n at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\n at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\n at System.Windows.Application.RunDispatcher(Object ignore)\n at System.Windows.Application.RunInternal(Window window)\n at System.Windows.Application.Run(Window window)\n at System.Windows.Application.Run()\n at WPFClickOnceDeploySample.App.Main()\n at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)\n at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)\n at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)\n at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()\n at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)\n at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)\n at System.Activator.CreateInstance(ActivationContext activationContext)\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\n at System.Threading.ExecutionContext.runTryCode(Object userData)\n at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\n at System.Threading.ThreadHelper.ThreadStart()\n InnerException: System.Security.SecurityException\n Message=Request for the permission of type \'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\' failed.\n Source=mscorlib\n StackTrace:\n at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)\n at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)\n at System.Security.CodeAccessPermission.Demand()\n at MS.Internal.SecurityHelper.DemandUnmanagedCode()\n at System.Windows.Window..ctor()\n at WPFClickOnceDeploySample.MainWindow..ctor()\n InnerException:\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
3030 次 |
最近记录: |