Security Error When calling assembly.CreateInstance

Discussion in 'ASP .Net Security' started by Roman, Nov 16, 2003.

  1. Roman

    Roman Guest

    I don't event know where to begin to solve it. I tried
    everything I could find on the net, with no avail. I ma
    loading an assembly using http. Here are the steps
    leanding to the assembly load and create object instance
    in this assembly:

    1. Assembly name definition

    AssemblyName assemblyName = new AssemblyName();
    assemblyName.CodeBase =
    @"http://localhost/Parsers/Ess/1.0.0.0/EdmXslParserEss.dll
    ";
    assemblyName.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
    assemblyName.VersionCompatibility =
    AssemblyVersionCompatibility.SameProcess;
    assemblyName.Flags = AssemblyNameFlags.PublicKey;
    assemblyName.KeyPair = new StrongNameKeyPair(File.Open
    (@"C:\Key.snk", FileMode.Open,
    FileAccess.Read));assemblyName.Version = new
    System.Version("1.0.0.0");

    2. Assambly load

    Assembly assembly = AppDomain.CurrentDomain.Load
    (assemblyName);

    3. Create an object

    EdmBaseParser parser = assembly.CreateInstance
    (edmLaboratoryModel.Parser, true,
    BindingFlags.CreateInstance, null, new object[]{}, null,
    null) as EdmBaseParser;

    That is where I am getting the "Security Error"
    (System.Security.SecurityException).


    The object that get created (EdmBaseParser) uses an
    introp.Excel which is a local resource. But I am using
    strong names so it shouldn't be a problem.
    Roman, Nov 16, 2003
    #1
    1. Advertising

  2. Send complete error stack trace!!!

    "Roman" <> wrote in message
    news:02e101c3ac55$4a097fc0$...
    > I don't event know where to begin to solve it. I tried
    > everything I could find on the net, with no avail. I ma
    > loading an assembly using http. Here are the steps
    > leanding to the assembly load and create object instance
    > in this assembly:
    >
    > 1. Assembly name definition
    >
    > AssemblyName assemblyName = new AssemblyName();
    > assemblyName.CodeBase =
    > @"http://localhost/Parsers/Ess/1.0.0.0/EdmXslParserEss.dll
    > ";
    > assemblyName.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
    > assemblyName.VersionCompatibility =
    > AssemblyVersionCompatibility.SameProcess;
    > assemblyName.Flags = AssemblyNameFlags.PublicKey;
    > assemblyName.KeyPair = new StrongNameKeyPair(File.Open
    > (@"C:\Key.snk", FileMode.Open,
    > FileAccess.Read));assemblyName.Version = new
    > System.Version("1.0.0.0");
    >
    > 2. Assambly load
    >
    > Assembly assembly = AppDomain.CurrentDomain.Load
    > (assemblyName);
    >
    > 3. Create an object
    >
    > EdmBaseParser parser = assembly.CreateInstance
    > (edmLaboratoryModel.Parser, true,
    > BindingFlags.CreateInstance, null, new object[]{}, null,
    > null) as EdmBaseParser;
    >
    > That is where I am getting the "Security Error"
    > (System.Security.SecurityException).
    >
    >
    > The object that get created (EdmBaseParser) uses an
    > introp.Excel which is a local resource. But I am using
    > strong names so it shouldn't be a problem.
    >
    Ram Sunkara [msft], Nov 17, 2003
    #2
    1. Advertising

  3. Roman

    Roman Guest

    Sorry, I was away yestarday. Here is the stck trace;

    StackTrace " at
    System.Security.CodeAccessSecurityEngine.CheckHelper
    (PermissionSet grantedSet, PermissionSet deniedSet,
    CodeAccessPermission demand, PermissionToken permToken)
    at Excel.ApplicationClass.get_Workbooks()
    at
    Com.Abetelo.Edm.Parsers.EdmBaseParser.AllocateExcelWorkshe
    et(String fileName) in c:\documents and settings\keith
    sullivan\my documents\aif\presentation - windows
    forms\edmparser\edmbaseparser.cs:line 125
    at Com.Abetelo.Edm.Parsers.Ess.EdmXslParserEss.Parse
    (String fileName) in c:\documents and settings\keith
    sullivan\my documents\aif\presentation - windows
    forms\edmxslparseress\edmxslparseress.cs:line 116
    at Com.Abetelo.Edm.EdmParserManager.Parser(String
    fileName) in c:\documents and settings\keith sullivan\my
    documents\aif\presentation - windows
    forms\edmapplication\edmparsermanager.cs:line 158
    at Com.Abetelo.Edm.EdmApplication.Initialize() in
    c:\documents and settings\keith sullivan\my
    documents\aif\presentation - windows
    forms\edmapplication\edmapplication.cs:line 80
    at Com.Abetelo.Edm.EdmApplication..ctor(XmlDocument
    xplXmlDocument) in c:\documents and settings\keith
    sullivan\my documents\aif\presentation - windows
    forms\edmapplication\edmapplication.cs:line 58
    at Com.Abetelo.Edm.EdmApplication.Main() in
    c:\documents and settings\keith sullivan\my
    documents\aif\presentation - windows
    forms\edmapplication\edmapplication.cs:line 185"
    string




    >-----Original Message-----
    >Send complete error stack trace!!!
    >
    >"Roman" <> wrote in

    message
    >news:02e101c3ac55$4a097fc0$...
    >> I don't event know where to begin to solve it. I tried
    >> everything I could find on the net, with no avail. I ma
    >> loading an assembly using http. Here are the steps
    >> leanding to the assembly load and create object

    instance
    >> in this assembly:
    >>
    >> 1. Assembly name definition
    >>
    >> AssemblyName assemblyName = new AssemblyName();
    >> assemblyName.CodeBase =
    >>

    @"http://localhost/Parsers/Ess/1.0.0.0/EdmXslParserEss.dll
    >> ";
    >> assemblyName.HashAlgorithm =

    AssemblyHashAlgorithm.SHA1;
    >> assemblyName.VersionCompatibility =
    >> AssemblyVersionCompatibility.SameProcess;
    >> assemblyName.Flags = AssemblyNameFlags.PublicKey;
    >> assemblyName.KeyPair = new StrongNameKeyPair(File.Open
    >> (@"C:\Key.snk", FileMode.Open,
    >> FileAccess.Read));assemblyName.Version = new
    >> System.Version("1.0.0.0");
    >>
    >> 2. Assambly load
    >>
    >> Assembly assembly = AppDomain.CurrentDomain.Load
    >> (assemblyName);
    >>
    >> 3. Create an object
    >>
    >> EdmBaseParser parser = assembly.CreateInstance
    >> (edmLaboratoryModel.Parser, true,
    >> BindingFlags.CreateInstance, null, new object[]{},

    null,
    >> null) as EdmBaseParser;
    >>
    >> That is where I am getting the "Security Error"
    >> (System.Security.SecurityException).
    >>
    >>
    >> The object that get created (EdmBaseParser) uses an
    >> introp.Excel which is a local resource. But I am using
    >> strong names so it shouldn't be a problem.
    >>

    >
    >
    >.
    >
    Roman, Nov 19, 2003
    #3
  4. Roman

    Guest Guest

    Ram,

    I am getting out of my mind dealing with this problem.
    What do you think I should do.

    Roman
    Guest, Nov 19, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nancy Sui
    Replies:
    1
    Views:
    2,556
    Scott Allen
    Nov 30, 2004
  2. Just D.
    Replies:
    0
    Views:
    425
    Just D.
    Dec 7, 2005
  3. Just D.
    Replies:
    0
    Views:
    449
    Just D.
    Dec 7, 2005
  4. Replies:
    3
    Views:
    1,810
  5. Nancy Sui
    Replies:
    1
    Views:
    141
    Scott Allen
    Nov 30, 2004
Loading...

Share This Page