如何让我的应用程序部署正常运行?
我使用 Visual Studio 2010 创建了一个新的简单 WPF 项目,并对项目的属性进行了以下修改:
->签名:创建测试证书并对两个程序集和清单进行签名。没有选中“仅延迟签名”框
->安全性:选中“启用单击一次安全设置”复选框和“这是部分信任设置”单选按钮。区域:“本地 Intranet”。
->安全性,高级:使用选定的安全设置调试此应用程序(我选择此一项)。
开始调试时,我收到“System.Security.Permissions.SecurityPermission,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”类型权限的请求失败。
安装时,应用程序将被安装,但启动时什么也没有发生。在另一台计算机上,将显示 bla bla 已停止工作(启动实用程序)。
操作系统:Windows 7。
通过一些实验,我发现将标志UnmanagedCode添加到SecurityPermission可以解决问题。为什么一个简单的 WPF 应用程序(一个新创建的 hello world)需要调用非托管代码?这是一个像火山一样大的安全漏洞。
感谢您的任何提示
How can I get my application deployment working?
I created a new simple WPF project with Visual Studio 2010 and did the following modifications in the properties of the project:
-> Signing: Created test certificate and signed both the assemblies an manifests. Did not check the box "delayed sign only"
-> Security: Checked box "enable click once security settings" and radio button "This is a partial trust settings". Zone: "Local Intranet".
-> Security, Advanced: Debug this application with the selected security settings (I choose this one).
When starting debugging, i get a Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
When installing, the application will be installed but just nothing happens when starting it. On another computer, a bla bla has stoped working (launch utility) will be shown.
OS: Windows 7.
With some experiments, I found out that adding the flag UnmanagedCode to the SecurityPermission solved the problem. Why is a simple WPF application (a freshly created hello world) in need to call unmanaged code? This is a security hole as big as a volcano.
Thanks for any hint
发布评论
评论(1)
聚会迟到了,但这是我发现的(同时偶然发现同样的问题)。
看来 WPF
Window
确实需要UnmanagedCode
权限。摘自C# 中的 Pro WPF 4.5:.NET 4.5 中的 Windows Presentation Foundation。
而且,这是当运行通过部分信任中的 ClickOnce 部署的 WPF 应用程序时,异常的堆栈跟踪。请注意从
Window
的构造函数调用SecurityHelper
的DemandUnmanagedCode
函数:并且,这是完整的 StackTrace:
Late to the party but here's what I have found (while stumbling upon same problem) .
It seems that WPF
Window
does requireUnmanagedCode
permission.Excerpt from Pro WPF 4.5 in C#: Windows Presentation Foundation in .NET 4.5 by Matthew MacDonald.
And, here's the stack trace of exception, when WPF application deployed via ClickOnce in Partial Trust is run. Notice the call to
DemandUnmanagedCode
function ofSecurityHelper
from the constructor ofWindow
:And, here's the full StackTrace: