Debug Session on localhost

J

Jason

Hi folks. Please help a newbie...

I'm using VS2008 and I've built a small Asp.net application

When I go to debug it I get a security exception.

Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Web.AspNetHostingPermission, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Here's the stack trace:


[SecurityException: Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Reflection.Assembly._GetType(String name, Boolean throwOnError,
Boolean ignoreCase) +0
System.Reflection.Assembly.GetType(String name, Boolean throwOnError,
Boolean ignoreCase) +30
System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String
typeName, Boolean ignoreCase) +119
System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase,
Boolean throwOnError) +179
System.Web.UI.TemplateParser.ProcessInheritsAttribute(String
baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +95

System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary
parseData) +192
 
G

Guest

Hi folks. Please help a newbie...

I'm using VS2008 and I've built a small Asp.net application

When I go to debug it I get a security exception.

Description: The application attempted to perform an operation not allowed
by the security policy.  To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Web.AspNetHostingPermission, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Here's the stack trace:

[SecurityException: Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Reflection.Assembly._GetType(String name, Boolean throwOnError,
Boolean ignoreCase) +0
   System.Reflection.Assembly.GetType(String name, Boolean throwOnError,
Boolean ignoreCase) +30
   System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String
typeName, Boolean ignoreCase) +119
   System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase,
Boolean throwOnError) +179
   System.Web.UI.TemplateParser.ProcessInheritsAttribute(String
baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +95

System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary
parseData) +192

--------------------------------------------------------------------------- -----
Version Information: Microsoft .NET Framework Version:2.0.50727.1873;
ASP.NET Version:2.0.50727.1433

What version of IIS do you use? If you run it on IIS7, then check what
app pool identity you have. If it's not NetworkService, try to change
it.
More regarding Application Pool Identities on IIS/:
http://learn.iis.net/page.aspx/624/application-pool-identities/
 
J

Jason

Thanks for you reply Alexey,

I do not have IIS installed. It's not in "Add Remove Windows Components".
(WinXP)
I will try that.

It works OK on another machine which does not have IIS. So what does it run
on? It says localhost and a random port number.

Thanks
Jason
 
J

Jason

Sorry - just learning - It must be the ASP.NET Development Server. Does this
need coniguring? if so - how?
 
A

Andrew Morton

Jason said:
I do not have IIS installed. It's not in "Add Remove Windows
Components". (WinXP)
I will try that.

It works OK on another machine which does not have IIS. So what does
it run on? It says localhost and a random port number.

Does it work if you run your VS in an account with administrator privileges?
 
Z

Zhi-Qiang Ni[MSFT]

Hi Jason,

The error message indicates the application attempted to perform an
operation not allowed by the security policy. It is probably the trust
level is incorrectly configured for you application.

By default , the trust level is full , all privileged operations are
supported. When an ASP.NET application domain is created, ASP.NET reads
the value specified for the level attribute of the trust configuration
element, creates an instance of the AspNetHostingPermission class with the
specified Level attribute, and then adds the class to the permission set
for the application domain. You will see the above error if the trust
levels are incorrectly configured or modified.

In this case, the trust configuration element in root web.config on your
problem machine might be modified or it was override in a sub web.config
file in your application. You can modify the trust level back to full by
adding the following configuration section in the web.config file in your
site root.

<configuration>
<system.web><trust level="full" originUrl="" /></system.web>
</configuration>

Here is some related information about the ASP.Net Trust Levels and Policy
files, for your reference:
trust Element (ASP.NET Settings Schema)
http://msdn.microsoft.com/en-us/library/tkscy493.aspx
http://support.microsoft.com/kb/910449
http://msdn.microsoft.com/en-us/library/xady2w27(v=VS.100).aspx
http://msdn.microsoft.com/en-us/library/wyts434y.aspx

If you problem persists, please feel free to let me know. Thanks.

--
Sincerely,
Zhi-Qiang Ni
Microsoft Online Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top