Configuring Security for a Windows Forms Element Hosted in Internet Explorer

I have created a Windows Control that is hosted on a web page visible with Internet Explorer.

My control is read from the COM port and written to the event log. Both of these operations fail by default when the infrastructure asks for the appropriate permissions. This web application will always run on the intranet zone, how do I enable these operations?

Serial Port Code Bits and Errors:

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

      

A permission request of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 failed.

Event log code bits and error:

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

      

A permission request of type 'System.Diagnostics.EventLogPermission, system, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 failed.

The 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>

      

0


source to share


2 answers


You will need to create an installer or give users a higher level of trust for your site. These parameters can be edited in the Microsoft .NET Framework configuration. in the Administration section. You can also take a look at Chris Sells Wahoo which uses the installer to grant these permissions



+1


source


I've struggled with this in the past and tried to raise permissions using caspol and it was a real pain. I finished converting it to one app at a time in 30 minutes and have never had any problems with it.



0


source







All Articles