简体   繁体   English

为Internet Explorer中托管的Windows窗体控件配置安全性

[英]Configuring security for a windows forms control hosted in Internet Explorer

I've created a windows forms control, which is hosted in a web page viewable with Internet Explorer. 我创建了一个Windows窗体控件,该控件托管在Internet Explorer可见的网页中。

My control reads from a com port and it writes to the event log. 我的控件从com端口读取,并将其写入事件日志。 Both of these operations by default fail when the framework requests proper permissions. 默认情况下,当框架请求适当的权限时,这两项操作都会失败。 This web application will always be running in the intranet zone, how do I enable these operations? 此Web应用程序将始终在Intranet区域中运行,如何启用这些操作?

Serial port code bits & error: 串行端口代码位和错误:

private System.IO.Ports.SerialPort portCardReader_m = new System.IO.Ports.SerialPort();
portCardReader_m.PortName = value;
portCardReader_m.Open();  //Exception here

Request for the permission of type 'System.Security.Permissions.SecurityPermission,mscorlib, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089 failed. 请求类型为'System.Security.Permissions.SecurityPermission,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089的权限失败。

Event Log code bits & error: 事件日志代码位和错误:

System.Diagnostics.EventLog pEventLog = new System.Diagnostics.EventLog("Application", ".", this.GetType().FullName);
pEventLog.WriteEntry(this.Text, System.Diagnostics.EventLogEntryType.Error); //Exception Here

Request for the permission of type 'System.Diagnostics.EventLogPermission,System, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089 failed. 请求类型为'System.Diagnostics.EventLogPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089的权限失败。

Code to embed my control in the browser: 将我的控件嵌入浏览器的代码:

<object width="600px" height="300px" id="objCardReader" classid="cardreader.dll#CardReader">
    <param name="Text" value="Testing" />
    <param name="PortName" value="COM5" />
</object>

You would need to create an installer or have your users grant a higher trust level for your website. 您将需要创建安装程序,或者让您的用户为您的网站授予更高的信任级别。 These settings are editable under Microsoft .NET Framework configuration. 这些设置可以在Microsoft .NET Framework配置下进行编辑。 under Administrative Tools. 在管理工具下。 You can also take a look at Chris Sells Wahoo which uses an installer to grant these permissions 您还可以查看Chris Sells Wahoo ,它使用安装程序授予这些权限

I've struggled with this in the past and tried to elevate permissions using caspol and it was a real pain. 过去,我一直在为此苦苦挣扎,并尝试使用caspol提升权限,这确实很痛苦。 I ended up converting it to a click once app in 30 minutes and never had a problem with it since. 我最终在30分钟内将其转换为单击一次应用程序,此后再也没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 7上的Internet Explorer 6.0的IE ActiveX控件 - IE ActiveX control for internet explorer 6.0 on Windows 7 更改Internet Explorer的安全设置(初始化和未编写ActiveX控件脚本…) - Change internet explorer security settings(initaize and script activex control not maked …) 我是否可以告诉托管的Internet Explorer Web浏览器控件始终绕过代理设置? - Will I be able to tell a Hosted Internet Explorer Web Browser control to always bypass the proxy settings? 更改Internet Explorer的安全设置 - Change internet explorer security settings 使用C#控制Internet Explorer - Control Internet Explorer with C# Windows文件浏览器控件 - Windows File Explorer control Selenium:在Internet Explorer中将文件下载到指定的文件夹,而无需直接链接,没有Windows窗体,没有AutoIt或Robot - Selenium: download file in Internet Explorer to specified folder without direct link, without Windows Forms, without AutoIt or Robot WPF的Windows资源管理器控件? - Windows Explorer control for WPF? Windows Mobile Internet Explorer历史记录 - Windows Mobile Internet Explorer History C#WebDriver Internet Explorer安全提示 - C# WebDriver Internet Explorer Security Prompts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM