Re: Odd StrongNameIdentityPermission failure during an NUnit run

From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 10/07/03


Date: Tue, 7 Oct 2003 17:06:04 +0300

Hi Joannes,

This exception should have nothing to do with NTFS security. It is usually
raised when calling code does not have sufficient permissions to call some
method. Sounds odd? Yes, it does indeed in the beginning but as I have gone
through with it already, I'll try to explain in plain English (while it is
not my mother tongue, he-he :-)

So this type of security is intended to protect your code from unathorized
calls. There's an attribute you can apply to a method, and after that an
assembly calling this method will have to have certain strong name
(specified in the attribute's constructor), or the assembly won't be allowed
to call your method and the exception you have seen will be thrown.

What's strange indeed the exception is raised only once. What you can to is
have the debugger break once this exception has been thrown and see whether
it is thrown from your code or from inside the NUnit runtime. If the latter
is the case, you should probably contact the NUnit development team. And if
your own code is the culprit, you probably know what to do with it :-)

-- 
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Joannes Vermorel" <firstname@lastname.com> wrote in message
news:uJbXFA4iDHA.360@TK2MSFTNGP10.phx.gbl...
> I am currently writing a C# library. The library incorporates its own
NUnit
> testing suite.
>
> When I run the NUnit Gui (www.nunit.org) for the first on time on the
> library (after starting the NUnit Gui), I got the following error:
>
> > MyMethodName: Request for the permission of the type
> > System.SecurityPermission.StrongNameIdentityPermission, mscorlib, [..
> skipped ..] failed
> >
> > at System.Xml.XmlTextReader..ctor(String url, XmlNameTable nt)
> > at System.Xml.XmlTextReader..ctor(String url)
> > at MyMethodName()
>
> When I run the tests again (1x, 2x, 10x, ...), everything works fine, and
no
> more security permission fails (until I restart NUnit). This behavior
seems
> very strange to me. I understand that a disk access could fail depending
on
> the security settings, but I don't see any reason why an access that was
> first denied could be granted the second time ???
>
> Does someone has an explanation for this ?
>
> Thanks for the help,
> Joannes Vermorel
>
>