Security Exception - Winform usercontrol hosted in ASP.NET

S

Scott Leonard

Please forgive the lengthy post. I am trying to get my winform usercontrol
to work properly when hosted in ASP.NET. It is strongly named and has the
APTC attribute set. I am using some Infragistics controls, all of which are
strongly named and have APTC set. I need "Full Trust" or "Everything" access
since I am doing some MySQL queries, creating sockets, doing DNS lookups,
etc.

The only way I can get it to work is to:
1. Add my web site to the trusted sites in IE (don't mind that).
2. Set the trusted sites security to LOW in IE (don't mind that)
3. Change the permission on Machine->All_Code->Trusted_Zone from "Internet"
to "Full Trust" or "Everything" (don't like that)

I have tried creating an Enterprise level Code Group with SN membership for
my assembly with "Full Trust" permissions and all combinations of the
"Exclusive" and "NoLowerLevel" properties. That doesn't work, but it should.
I have also tried the same thing at the Machine level. I've tried both of
these with and without steps 1 and 2 above.
I also created an Enterprise level "Trusted_Zone" with "Full Trust" and
created my SN "Full Trust" group under that (with combinations of the
"Exclusive" and "ThisLevelOnly" properties) with my site in the Trusted
Sites and that didn't work, either.
I have tried many combinations and the steps above are the only way I can
get it to work.

I want to create a machine level code group that gives my web hosted,
strongly named app "Full Trust" or "Everything" (without granting the same
permissions to other web sites carte blanc). I have tried this with the
"Exclusive" and "NoLowerLevel" options and it didn't work, but it should,
right? I've also used the "Evaluate Assembly" tool with all these different
policy combinations, giving it the full url of my assembly (e.g.
www.internet.net/mxrtest/mxreseller.dll) and it says it has the "Full Trust"
or "Everything" permissions. It seems like some other thing is limiting the
permissions somehow.

Also:
1. I haven't played around with custom permission sets (I'd rather just use
one of the defaults)
2. I haven't played around with anything in the Policy Assemblies section.
3. I haven't added any special security code to my app (declarations,
requests, asserts, etc.) and I'd rather not if I can just set up the
security policy the right way.

TIA from a frustrated coder,
sbl

************** Exception Text **************
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.UIPermission, 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.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.Windows.Forms.Control.Focus()
at mxReseller.ucReseller.ucReseller_Load(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.OnMessag
e(Message& m)
at
System.Windows.Forms.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessag
e(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
RegexAssembly6_0
Assembly Version: 0.0.0.0
Win32 Version: n/a
CodeBase:
----------------------------------------
mxReseller
Assembly Version: 1.0.0.9
Win32 Version: n/a
CodeBase:
http://www.internet.net/mxrtest/(pmtaj0er0lueyp55erdgoj55)/mxReseller.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
Infragistics.Win.UltraWinEditors.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.ultrawineditors.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.ultrawineditors.v3.1.dll
----------------------------------------
Infragistics.Win.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.v3.1.dll
----------------------------------------
Infragistics.Shared.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.shared.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.shared.v3.1.dll
----------------------------------------
Infragistics.Win.Misc.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.misc.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.misc.v3.1.dll
----------------------------------------
Infragistics.Win.UltraWinGrid.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.ultrawingrid.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.ultrawingrid.v3.1.dll
----------------------------------------
Microsoft.mshtml
Assembly Version: 7.0.3300.0
Win32 Version: 7.0.3300.0
CodeBase:
file:///c:/windows/assembly/gac/microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/microsoft.mshtml.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
 
C

chris bamert

Hello

I've got the same problem with the Janus-Library.
First, is it required to use strong names?
What do you mean with APTC?

Do have a solution now?

Thanks
Chris
 
S

Scott Leonard

I don't think you _HAVE_ to use strong names, I sign and obfuscate my code
as a matter of course. The strong name seemed like the easiest way to
uniquely identify my code for a policy, though.

APTC = allowpartiallytrustedclient. You'll need this attribute in your
assemblyinfo. Check MSDN for details...

I have a workaround, not a solution. I add my site to the trusted sites in
IE, and set the trusted sites zone to default security (Low). Then in the
policy manager, I create a policy for my site (at the enterprise or machine
level), giving it FullTrust and NoLower (at the enterprise level) or
FullTrust, Exclusive and NoLower (at the machine level). This seems to work
for me. It is not the solution I want, because it ties me to a web site. I
would rather use a strong name, which is less likely to change over time.

sbl

chris bamert said:
Hello

I've got the same problem with the Janus-Library.
First, is it required to use strong names?
What do you mean with APTC?

Do have a solution now?

Thanks
Chris

Scott Leonard said:
Please forgive the lengthy post. I am trying to get my winform usercontrol
to work properly when hosted in ASP.NET. It is strongly named and has the
APTC attribute set. I am using some Infragistics controls, all of which are
strongly named and have APTC set. I need "Full Trust" or "Everything" access
since I am doing some MySQL queries, creating sockets, doing DNS lookups,
etc.

The only way I can get it to work is to:
1. Add my web site to the trusted sites in IE (don't mind that).
2. Set the trusted sites security to LOW in IE (don't mind that)
3. Change the permission on Machine->All_Code->Trusted_Zone from "Internet"
to "Full Trust" or "Everything" (don't like that)

I have tried creating an Enterprise level Code Group with SN membership for
my assembly with "Full Trust" permissions and all combinations of the
"Exclusive" and "NoLowerLevel" properties. That doesn't work, but it should.
I have also tried the same thing at the Machine level. I've tried both of
these with and without steps 1 and 2 above.
I also created an Enterprise level "Trusted_Zone" with "Full Trust" and
created my SN "Full Trust" group under that (with combinations of the
"Exclusive" and "ThisLevelOnly" properties) with my site in the Trusted
Sites and that didn't work, either.
I have tried many combinations and the steps above are the only way I can
get it to work.

I want to create a machine level code group that gives my web hosted,
strongly named app "Full Trust" or "Everything" (without granting the same
permissions to other web sites carte blanc). I have tried this with the
"Exclusive" and "NoLowerLevel" options and it didn't work, but it should,
right? I've also used the "Evaluate Assembly" tool with all these different
policy combinations, giving it the full url of my assembly (e.g.
www.internet.net/mxrtest/mxreseller.dll) and it says it has the "Full Trust"
or "Everything" permissions. It seems like some other thing is limiting the
permissions somehow.

Also:
1. I haven't played around with custom permission sets (I'd rather just use
one of the defaults)
2. I haven't played around with anything in the Policy Assemblies section.
3. I haven't added any special security code to my app (declarations,
requests, asserts, etc.) and I'd rather not if I can just set up the
security policy the right way.

TIA from a frustrated coder,
sbl

************** Exception Text **************
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.UIPermission, 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.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.Windows.Forms.Control.Focus()
at mxReseller.ucReseller.ucReseller_Load(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.OnMessag
e(Message& m)
at
System.Windows.Forms.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessag
e(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
RegexAssembly6_0
Assembly Version: 0.0.0.0
Win32 Version: n/a
CodeBase:
----------------------------------------
mxReseller
Assembly Version: 1.0.0.9
Win32 Version: n/a
CodeBase:
http://www.internet.net/mxrtest/(pmtaj0er0lueyp55erdgoj55)/mxReseller.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
Infragistics.Win.UltraWinEditors.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.ultrawineditors.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.ultrawineditors.v3.1.dll
----------------------------------------
Infragistics.Win.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.v3.1.dll
----------------------------------------
Infragistics.Shared.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.shared.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.shared.v3.1.dll
----------------------------------------
Infragistics.Win.Misc.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.misc.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.misc.v3.1.dll
----------------------------------------
Infragistics.Win.UltraWinGrid.v3.1
Assembly Version: 3.1.20041.1036
Win32 Version: 3.1.20041.1036
CodeBase:
file:///c:/windows/assembly/gac/infragistics.win.ultrawingrid.v3.1/3.1.20041.1036__7dd5c3163f2cd0cb/infragistics.win.ultrawingrid.v3.1.dll
----------------------------------------
Microsoft.mshtml
Assembly Version: 7.0.3300.0
Win32 Version: 7.0.3300.0
CodeBase:
file:///c:/windows/assembly/gac/microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/microsoft.mshtml.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top