Re: Strange permission issue with a UserControl

From: ejstembler (ejstembler_at_discussions.microsoft.com)
Date: 12/21/04


Date: Tue, 21 Dec 2004 08:03:02 -0800

It's a custom delegate (and corresponding custom EventArgs) which is declared
in the referenced assembly (dll). The UserControl in the WinForms assembly
(exe) implements the delegate as an event.

The error messages are indicitive of it having less rights, such as the
Local Network Zone, or Internet Zone. Even if I change both assemlies to
FullTrust using the "Trust an Assembly" wizard it has no effect. In fact, I
don't even see them listed when I run caspol.exe -lf

I'll post the error messages later today...

"Nicole Calinoiu" wrote:

> 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" <ejstembler@discussions.microsoft.com> wrote in message
> news:530F047D-6260-49CF-9F75-FEA841FE125C@microsoft.com...
> > 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?
>
>
>



Relevant Pages

  • Re: Strange permission issue with a UserControl
    ... The UserControl in the WinForms ... > implements the delegate as an event. ... > I'll post the error messages later today... ... Does the UserControl inherit from a base class ...
    (microsoft.public.dotnet.security)
  • Z-order on my custom control at design-time is wrong
    ... I've created a very simple custom "UserControl" that has a Panel docked to ... I've decorated my custom control with the: ... So, I go ahead and drop my custom usercontrol onto a Form, and then drop two ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: VB calling DLL only with _stdcall?
    ... calls a subclass function from inside a userControl, ... my own custom RichTextBox based on riched20.dll, ... dozen subclasses on those controls with no hassle at all. ... might not have a lot of time to get your money's worth. ...
    (comp.lang.basic.visual.misc)
  • Re: Small Doubt
    ... you use an UserControl when its output will be mainly ... static and you use a custom control when its output will be mainly dynamic. ... If you're interested in learning about custom controls you should definitely ... > What is the difference b/w a usercontrol and a Custom Web Control? ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Cascading delegates
    ... I have a Usercontrol that is part of another usercontrol. ... In my child usercontrol, I use a delegate to pass an event with some data to the parent usercontrol. ...
    (microsoft.public.dotnet.languages.csharp)