簡體   English   中英

為Internet Explorer中托管的Windows窗體控件配置安全性

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

我創建了一個Windows窗體控件,該控件托管在Internet Explorer可見的網頁中。

我的控件從com端口讀取,並將其寫入事件日志。 默認情況下,當框架請求適當的權限時,這兩項操作都會失敗。 此Web應用程序將始終在Intranet區域中運行,如何啟用這些操作?

串行端口代碼位和錯誤:

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

請求類型為'System.Security.Permissions.SecurityPermission,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089的權限失敗。

事件日志代碼位和錯誤:

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

請求類型為'System.Diagnostics.EventLogPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089的權限失敗。

將我的控件嵌入瀏覽器的代碼:

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

您將需要創建安裝程序,或者讓您的用戶為您的網站授予更高的信任級別。 這些設置可以在Microsoft .NET Framework配置下進行編輯。 在管理工具下。 您還可以查看Chris Sells Wahoo ,它使用安裝程序授予這些權限

過去,我一直在為此苦苦掙扎,並嘗試使用caspol提升權限,這確實很痛苦。 我最終在30分鍾內將其轉換為單擊一次應用程序,此后再也沒有任何問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM