By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,084 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Security issue running unmanaged code in a win form ctrl hosted in

P: n/a
Security problem running unmanaged code (.ocx control) in a windows from
control hosted in IE6
Hi,
I have design a windows from control which contain a .OCX in one of its
forms.
Component developed in C#2005 -------- .NET2

Now, the control is loaded successful via IIS in my web application. Now
when I try to load the form where the OCX is hosted:

private void button2_Click(object sender, EventArgs e)
{
Form1 a;
a = new Form1();
a.ShowDialog();
}

I got an .NET Excpetion saying:

System.Security.SecurityException: Request failed.
************** Exception Text **************
System.Security.SecurityException: Request failed.
at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
at System.Windows.Forms.AxHost..ctor(String clsid)
at AxAcroPDFLib.AxAcroPDF..ctor()
at WindowsControlLibrary1.Form1.InitializeComponent()
at WindowsControlLibrary1.Form1..ctor()
at WindowsControlLibrary1.UserControl1.button2_Click( Object sender,
EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
The action that failed was:
Demand
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.PermissionSet
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)

.......................

Now the permissions for the windows from control are set to unrestricted. (I
have Double-checked it via the framework evaluation permission option for
assemblies persent in .NET)

Tried the following in the AssemblyInfo.cs

[assembly: AllowPartiallyTrustedCallers()]
[assembly: SecurityPermissionAttribute(SecurityAction.Request Minimum, Flags
= SecurityPermissionFlag.UnmanagedCode)]
[assembly: SecurityPermissionAttribute(SecurityAction.Request Minimum, Flags
= SecurityPermissionFlag.ControlEvidence)]
[assembly: SecurityPermissionAttribute(SecurityAction.Request Minimum, Flags
= SecurityPermissionFlag.SkipVerification)]
[assembly: SecurityPermissionAttribute(SecurityAction.Request Minimum, Flags
= SecurityPermissionFlag.AllFlags)]
tried:

[SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)]
[SecurityPermission(SecurityAction.Assert, ControlEvidence = true)]
[SecurityPermission(SecurityAction.Assert, Unrestricted = true)]
no luck!!!!

Any idea how to run unmanged code in a window from hosted in IE6?
Many Thanks,
Filippo Bettinaglio


Mar 29 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.