Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c# activex - System.Security.SecurityException: Request for the permi

Status
Not open for further replies.

chennaiprogrammer

Programmer
Jul 31, 1999
54
I create a simple activex dll using c# the snippet of code is

==============================

new FileIOPermission(PermissionState.Unrestricted).Assert();
string[] str=Directory.GetLogicalDrives();
int len = str.Length;
for(int i = 0; i < len; i++)
{
Button btn = new Button();
btn.Text = str.ToString();
btn.BackColor = System.Drawing.Color.LightGray;
btn.Width = 42;
btn.Height = 42;
btn.Location = new System.Drawing.Point(32,btn.Height*i);
this.Controls.Add(btn);
}
FileIOPermission.RevertAssert();
========================

The above is for listing all drive names in a computer

Now when I access the activex from browser it says

************** Exception Text **************
System.Security.SecurityException: Request for the permission of type System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.CheckNReturnSO(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 unrestrictedOverride, Int32 create)
at System.Security.CodeAccessSecurityEngine.Assert(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Assert()
at testControl1.UserControl1.UserControl1Load(Object sender, EventArgs e)
at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
at System.Windows.Forms.UserControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessage(Message& m)
at System.Windows.Forms.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


and Im calling the activex from html page
like

<html>
<body>

<OBJECT id=UserControl1 height=472 width=488 classid=UserControl1.dll#testControl1.UserControl1
name=UserControl1></OBJECT>

</body>
</html>


I am looking for a solution where the client computer does not need many modifications to be done

There will be lots of clients who will be using this activex dll and I do not want to ask each and every client to change something in their computer ?

also when I script simple activex dll with simple form controls it works like a charm and does not show the above error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top