Code Access Security exception in subproject

  • Thread starter Thread starter DC
  • Start date Start date
D

DC

Hi,

I have a solution with an ASP.NET project and a business and a data
layer in separate projects. The following code

string test = System.Diagnostics.Process.GetCurrentProcess().ProcessName;

runs fine in the ASP.NET app and in the business layer, but throws a
security exception in the data layer. I don't know what's different in
the data layer, after all I did not specify any CAS rules or the like.
There is also no app.config for the datalayer.

Where else could this CAS rule be specified? Thanks for any hint!

Regards

DC
 
DC,

Can you give more details about the exception? Also, are these
libraries, or are you making calls through remoting, or into Enterprise
Services?
 
Thank you for your attention, Nicholas. It is a SecurityException in
mscorlib:

Request for the permission of
type System.Net.WebPermission, System, Version=1.0.5000.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.

I narrowed the problem; it actually has nothing to do with the
business or data layer. I am loading a webcontrol into a
webusercontrol (ascx) file. When I execute this:

System.Diagnostics.Process.GetCurrentProcess()

in the command window, I receive the exception in any method of the
webcontrol (while it is still working in the ascx file).

I have tried to reproduce the problem by creating a new web project
with a webcontrol library but I failed to get this exception. I have
checked that this new test web does have the exact same permissioning
and I am totally in the dark about why my CAS level "drops" within the
webcontrol. Since I have to do some refactoring anyhow, I will
recreate the project and hopefully not see the exception anymore.

However, it would be good to know what could cause the CAS level to
drop. I am not doing any fancy stuff like loading ressources from a
different web or machine. I ran into this problem, since I am trying
to use Enterprise Library V1.0 which obviously requires the highest
CAS level because it needs the current process name for its
performance counters.

Best regards
DC





Nicholas Paldino said:
DC,

Can you give more details about the exception? Also, are these
libraries, or are you making calls through remoting, or into Enterprise
Services?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DC said:
Hi,

I have a solution with an ASP.NET project and a business and a data
layer in separate projects. The following code

string test = System.Diagnostics.Process.GetCurrentProcess().ProcessName;

runs fine in the ASP.NET app and in the business layer, but throws a
security exception in the data layer. I don't know what's different in
the data layer, after all I did not specify any CAS rules or the like.
There is also no app.config for the datalayer.

Where else could this CAS rule be specified? Thanks for any hint!

Regards

DC
 
Back
Top