Re: StrongNameIdentityPermission issue.

From: Hernan de Lahitte (hernan_at_lagash.com)
Date: 04/28/04

  • Next message: rethna_24_at_yahoo.com: "IE hosting and security"
    Date: Wed, 28 Apr 2004 14:26:31 -0300
    
    

    Check the assembly version number where your Forms resides. Version numbers
    must be the same on both the asembly and on the linkdemand declaration. Your
    exception shows a version number of "1.0.5000.0" and on your LinkDemand
    declaration is "1.0.0.0".

    -- 
    Hernan de Lahitte
    Lagash Systems S.A.
    http://weblogs.asp.net/hernandl
    This posting is provided "AS IS" with no warranties, and confers no rights.
    "David Riddiford" <anonymous@discussions.microsoft.com> wrote in message
    news:1F50C7F9-5AB1-493E-A433-BA5B95EA82E5@microsoft.com...
    > Hi,
    >
    > I am having another problem with StrongNameIdentityPermission. I'll go
    through an example.
    >
    > I have two projects in a solution: MainApp and CallClass. MainApp is a
    WinForm project containing a form called MainForm. CallClass is a class
    library project containing a class called MyClass and a Form called
    SecondForm. MyClass has a public static method called LogonSucceed which
    simply returns a string.
    >
    > Both projects are strong named.
    >
    > Both classes in CallClass have the following strong name identity
    permission demand:
    > [StrongNameIdentityPermission(SecurityAction.LinkDemand,
    PublicKey="<public key>", Name="MainApp", Version="1.0.0.0")]
    >
    > The load method of MainForm is as follows:
    > private void MainForm_Load(object sender, System.EventArgs e)
    > {
    > try
    > {
    > MessageBox.Show(MyClass.LogonSucceed());
    > Form secondForm = new SecondForm();
    > secondForm.Owner = this;
    > secondForm.Show();
    > }
    > catch (SecurityException ex)
    > {
    > MessageBox.Show("MyClass is unavailable. " + ex.Message);
    > Application.Exit();
    > }
    > }
    >
    > When I run the app, the message box displays correctly, but when
    SecondForm is instantiated, a security exception occurs as follows:
    > Request for the permission of type
    System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
    Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<public key token>
    failed.
    >
    > Exactly the same Link Demand is performed on both classes in the CallClass
    project.  The call to a public static method works. Instantiating the form
    fails. Note that I checked that instantiating MyClass actually worked. Also,
    if I remove the name and version parameters to the strong name identity
    permission, instantiating the form will work.
    >
    > So it appears that StrongNameIdentityPermission does not work on WinForm
    classes if the name and version parameters are set, unless of course I am
    doing something wrong :-)
    >
    > Does anyone have any ideas as to why this behaviour is occuring, and how I
    can resolve this issue.
    >
    > Thanks,
    > David.
    

  • Next message: rethna_24_at_yahoo.com: "IE hosting and security"