Re: Strange permission issue with a UserControl

From: Nicole Calinoiu (calinoiu)
Date: 12/21/04

Date: Tue, 21 Dec 2004 09:00:33 -0500

Events cannot be directly declared within an assembly, so what exactly do
you mean by "it exposes a public event which declared in another assembly"?
Is only the delegate declared in the other assembly? Does the UserControl
implement an interface declared in the other assembly, and the interface
defines the event? Does the UserControl inherit from a base class defined
in the other assembly, and the base class defines the event? A combination
of the above? Something else entirely?

Also, would it be possible for you to provide the full exception details as
retrieved from a call to its ToString method?

"ejstembler" <> wrote in message
> I'm encountering a strange permission issue with a custom UserControl...
> The UserControl is part of a WinForms project (exe), however it exposes a
> public event which declared in another assembly (dll). Nothing out of the
> ordinary there. A winform (FormMain) in the exe project contains the
> custom
> UserControl on it, and implements the event. In the event, I call another
> method which calls a stored procedure and displays a MessageBox if it
> fails.
> If I call that method from any other method in the form (such as
> FormMain_Load) it works fine. If the method is called from the
> UserControl
> event it throws a SqlClientPermission error (which is never displayed) and
> then a UIPermission error when the MessageBox is attempted to be
> displayed.
> I'm assuming that the UserControl has less rights for some reason; but
> why?
> It's almost acting like it's treating it as though it's in another less
> trusted zone (such as Local Network, or Internet). Both the WinForm
> assembly
> (exe) and the referenced assembly (dll) are on the local computer. Even
> if I
> grant FullTrust to all of the assemblies in question, the .Net run-time
> still
> displays the security exception dialog.
> Any ideas?