Extremely freaky Security Exception

W

William Sullivan

I have a page that (simply put) displays information from a SQL database.
I've split off the business logic and database access logic into different
classes. My database access class exposes static methods for loading typed
datasets with information from the database. I call methods in this class
three times when my page loads. The first two methods I call work fine; they
return the data I expect from the database. The last method fails with a
Security Exception. The extremely freaky part is that when I follow the
execution while debugging, the exception is thrown exactly when I call the
method. Execution never enters the method. A snippet of code looks like:

this.securityData = DBHelper.GetSecurityData();

this.roomData = DBHelper.GetRoomData(this.userID);

CabinetData foo = DBHelper.GetCabinetData(roomServer, roomDbName, dbType);

the three methods do pretty much the same thing--connect to the database,
run a query, fill a typed dataset with the results, and return it. The only
difference is that the first two are instance variables, the third (foo) is a
local variable to the method where the calls occur. The exception is thrown
after the third line is reached and before stepping into the method. I want
to make this clear--the method GetCabinetData never executes; the exception
is thrown at the point where execution would normally transfer from the
calling method into GetCabinetData. I'm stumped. TIA.
 
W

William Sullivan

I caught the security exception, and the RefusedSet is
" [snip]Flags=\"UnmanagedCode\"[snip]

I never requested to run unmanaged code. I don't run unmanaged code. What
the heck is going on?
 
W

William Sullivan

Lesson: Never put anything in your code that you do not fully understand.
Even if FxCop tells you to.

[assembly:SecurityPermission(SecurityAction.RequestRefuse,
UnmanagedCode=true)]
 

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

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top