Hello there
I have some problems with the .NET Security. I am developping an UserControl which is similar to Windows Explorer.
I try to add this control to a html page using the <Object> tag.
The control is indeed added but when loading, I get following Security Exception:
System.Security.SecurityException: Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_MachineName()
at UploadControl.Ecare.Upload.UploadControl.UploadControl_Load(Object sender, EventArgs e) in C:\Projects\apps\ecareUpload\UploadControl\UploadControl.vb:line 62
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)
So I understand that I can't access the Environment Variables as I am running the control from a WebServer (my local IIS). So I added localhost to the trusted sites and adjusted it's security to Full Trust. This didn't change anything. I also tried to Strong Name my assembly, without success. I used the .NET Framework Trust An Assembly wizard to give full Trust to my Assembly, but that didn't help either.
I thought that maybe it was due to the fact that I added a Windows Control to a WebForm. However, when adding the control to a windows form and running the Program from a shared drive on another machine, I get the same security Exception. Running it locally works fine.
I hope someone here can help as I am totally lost with all this Security stuff.
I have some problems with the .NET Security. I am developping an UserControl which is similar to Windows Explorer.
I try to add this control to a html page using the <Object> tag.
The control is indeed added but when loading, I get following Security Exception:
System.Security.SecurityException: Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_MachineName()
at UploadControl.Ecare.Upload.UploadControl.UploadControl_Load(Object sender, EventArgs e) in C:\Projects\apps\ecareUpload\UploadControl\UploadControl.vb:line 62
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)
So I understand that I can't access the Environment Variables as I am running the control from a WebServer (my local IIS). So I added localhost to the trusted sites and adjusted it's security to Full Trust. This didn't change anything. I also tried to Strong Name my assembly, without success. I used the .NET Framework Trust An Assembly wizard to give full Trust to my Assembly, but that didn't help either.
I thought that maybe it was due to the fact that I added a Windows Control to a WebForm. However, when adding the control to a windows form and running the Program from a shared drive on another machine, I get the same security Exception. Running it locally works fine.
I hope someone here can help as I am totally lost with all this Security stuff.