wpf 到底错在哪了?

booma 2007-07-21 08:30:42
<Window
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
Title='Hello World!'>
<Button>Hello World!</Button>
</Window>

xaml 的文件内容如上,保存后在浏览器上会出错如下错误:

Startup URI: D:\EBOOK\WPF\Essential.WPF\HelloWorld.xaml
Application Identity: file:///C:/WINDOWS/Microsoft.Net/Framework/v3.0/WPF/XamlViewer/XamlViewer_v0300.xbap#XamlViewer_v0300.application, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c3bce3770c238a49, processorArchitecture=msil/XamlViewer_v0300.exe, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c3bce3770c238a49, processorArchitecture=msil, type=win32

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
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()
.....

不知道是怎么回事?
...全文
288 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hm7921936 2007-07-24
  • 打赏
  • 举报
回复
System.Security.SecurityException
是.NET FRAMEWORK的SECURITY问题,设置为完全信任环境

仔细看了下.. 是的
hm7921936 2007-07-24
  • 打赏
  • 举报
回复
没装 07 什么意思?
像这种的就可以直接打开看到
<RichTextBox FontFamily="Palatino Linotype" FontSize="72" SpellCheck.IsEnabled="True" Typography.HistoricalLigatures="True" Typography.NumeralStyle="OldStyle" Typography.DiscretionaryLigatures="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />

用IE可以打开? 我尝试下.. 长见识了
jackjoy 2007-07-23
  • 打赏
  • 举报
回复
这是因为不管是松散的XAML文件,还是XBAP应用(WPF Browser Application),
如果是在浏览器(IE)中运行的化,都是运行在WPF Internet Sandbox沙箱中,
因而不具备创建窗口(Window)的权限,具体细节可以参考:
http://www.microsoft.com/china/msdn/library/security/wpfsecuritysandbox.mspx?mfr=true
simonezhlx 2007-07-23
  • 打赏
  • 举报
回复
帮顶
zhouyongh 2007-07-22
  • 打赏
  • 举报
回复
代码没问题 在XAMLPad上正常显示

System.Security.SecurityException
是.NET FRAMEWORK的SECURITY问题,设置为完全信任环境

加一段代码试试

using System.Security.Permissions;
[assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name="Internet")]
[assembly: PermissionSetAttribute(SecurityAction.RequestOptional,Unrestricted=true)]
booma 2007-07-22
  • 打赏
  • 举报
回复
没装 07 什么意思?
像这种的就可以直接打开看到
<RichTextBox FontFamily="Palatino Linotype" FontSize="72" SpellCheck.IsEnabled="True" Typography.HistoricalLigatures="True" Typography.NumeralStyle="OldStyle" Typography.DiscretionaryLigatures="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
hm7921936 2007-07-21
  • 打赏
  • 举报
回复
没装 07 帮UP下. 无法实验.. 记得给分~

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧