﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Andre Kraemer commented on Debugging Security Exceptions</title><description>I had a similar problem in a Sharepoint project. The SecurityException was thrown because of a missing permission. In order to find the permission I did the following:

I've surrounded the code that caused the error with a try catch block and caught the security exception. Then I've set a breakpoint in the catch block and had a look at the exception object in the quickwatch window. 

The security Exception has a private field called  m_demanded (among some other interesting fields), which finally told me what the missing permission was.

Maybe this helps in your case, too.</description><link>http://ayende.com/73729/debugging-security-exceptions#comment12</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment12</guid><pubDate>Wed, 31 Aug 2011 07:59:04 GMT</pubDate></item><item><title>Ayende Rahien commented on Debugging Security Exceptions</title><description>Dirk,
Not giving me details means _I can't fix this_. It is incredibly hard to figure out what is going on</description><link>http://ayende.com/73729/debugging-security-exceptions#comment11</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment11</guid><pubDate>Tue, 30 Aug 2011 00:54:27 GMT</pubDate></item><item><title>Dirk commented on Debugging Security Exceptions</title><description>Isn't this by design?

As it is a security exception it could be the result of someone probing trying to footprint the code.

Not giving any details might be annoying but it ticks the securtiy box.</description><link>http://ayende.com/73729/debugging-security-exceptions#comment10</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment10</guid><pubDate>Tue, 30 Aug 2011 00:47:40 GMT</pubDate></item><item><title>Steve Py commented on Debugging Security Exceptions</title><description>Hmm, at least from a debugging scenario, could  CodeAccessPermissions.Assert possibly loosen up the restrictions enough to get a stack-trace without compromising the security restriction causing the exception? Really not something I've ever been in this situation. </description><link>http://ayende.com/73729/debugging-security-exceptions#comment9</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment9</guid><pubDate>Tue, 30 Aug 2011 00:29:14 GMT</pubDate></item><item><title>Ayende Rahien commented on Debugging Security Exceptions</title><description>It doesn't tell me what caused the error (what line of code in the method)</description><link>http://ayende.com/73729/debugging-security-exceptions#comment8</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment8</guid><pubDate>Mon, 29 Aug 2011 22:43:36 GMT</pubDate></item><item><title>Keith Bloom commented on Debugging Security Exceptions</title><description>Can you catch the exception and use that to help you find the bug?

SecurityException has several properties which should help you to find out why it was raised.  This is turn may point to the code which caused it.

http://msdn.microsoft.com/en-us/library/system.security.securityexception_properties.aspx</description><link>http://ayende.com/73729/debugging-security-exceptions#comment7</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment7</guid><pubDate>Mon, 29 Aug 2011 22:35:14 GMT</pubDate></item><item><title>Ayende Rahien commented on Debugging Security Exceptions</title><description>Damien,
Try that :-)
It wouldn't get into the method / line that is causing it. It would stop when the JIT processed the method, not when executing it.</description><link>http://ayende.com/73729/debugging-security-exceptions#comment6</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment6</guid><pubDate>Mon, 29 Aug 2011 19:03:23 GMT</pubDate></item><item><title>Ayende Rahien commented on Debugging Security Exceptions</title><description>Tobi,
With the exception of things that are actually "if this fails, a restart is required"</description><link>http://ayende.com/73729/debugging-security-exceptions#comment5</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment5</guid><pubDate>Mon, 29 Aug 2011 19:02:41 GMT</pubDate></item><item><title>Ayende Rahien commented on Debugging Security Exceptions</title><description>Steve,
Nope, the line number was actually the function header, not any line in the method itself</description><link>http://ayende.com/73729/debugging-security-exceptions#comment4</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment4</guid><pubDate>Mon, 29 Aug 2011 19:01:56 GMT</pubDate></item><item><title>Damien Guard commented on Debugging Security Exceptions</title><description>Attach to web app, throw on exception?

[)amien</description><link>http://ayende.com/73729/debugging-security-exceptions#comment3</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment3</guid><pubDate>Mon, 29 Aug 2011 16:01:00 GMT</pubDate></item><item><title>tobi commented on Debugging Security Exceptions</title><description>Side note: never ever put anything that could remotely fail in a static constructor. Failing a static constructor causes the entire application to be effectively permanently unavailable until someone recycles the process. Only pure computations are suited for cctors. Use a static threadsafe lazy for anything else (but not the default one because it stores the exception! what an evil design choice).</description><link>http://ayende.com/73729/debugging-security-exceptions#comment2</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment2</guid><pubDate>Mon, 29 Aug 2011 12:44:31 GMT</pubDate></item><item><title>Steve Py commented on Debugging Security Exceptions</title><description>Doesn't the stack trace give you the detail you need to find the offending statement by line #?

The culprit from the original code was Line 166 inside DocumentDatabase.cs After your changes to track it down, the line was  185.

Or was the point that Line 166 was merely pointing at the constructor declaration, not the line that triggered the security exception?</description><link>http://ayende.com/73729/debugging-security-exceptions#comment1</link><guid>http://ayende.com/73729/debugging-security-exceptions#comment1</guid><pubDate>Mon, 29 Aug 2011 12:35:44 GMT</pubDate></item></channel></rss>