Security Error When calling assembly.CreateInstance

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Security Error When calling assembly.CreateInstance

    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 Guest

  2. Similar Questions and Discussions

    1. dynamically load DLL exception when calling Activator.CreateInstance(type, object[])
      I am trying to dynamically load a dll which specifies different rules for evalution with the following code. DataRow dr = ds.Tables.Rows; string...
    2. Problems with assembly security
      Hi Folks, I'm using a third-party module in my apllication to create PDFs. Most time the DDL works fine, but sometime I got the following error...
    3. How Do I get ConfigurationSettings from the calling assembly?
      I'm developing a server control for our intranet. This control is only going to be used in two applications on the server, but they must be...
    4. Calling a .NET Assembly from an ASP.NET page
      Do yoou mean that it calls a method of a class in an assembly? You may want to make the method call run in a separate thread. See the following...
    5. Calling .NET Assembly from JavaScript...
      I have a requirement to call .NET assembly (Custom component) from thin client Page (ASPX). This Assembly talks only TCP/IP with an external server...
  3. #2

    Default Re: Security Error When calling assembly.CreateInstance

    Send complete error stack trace!!!

    "Roman" <anonymous@discussions.microsoft.com> wrote in message
    news:02e101c3ac55$4a097fc0$a001280a@phx.gbl...
    > 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] Guest

  4. #3

    Default Re: Security Error When calling assembly.CreateInstance

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

    StackTrace " at
    System.Security.CodeAccessSecurityEngine.CheckHelp er
    (PermissionSet grantedSet, PermissionSet deniedSet,
    CodeAccessPermission demand, PermissionToken permToken)
    at Excel.ApplicationClass.get_Workbooks()
    at
    Com.Abetelo.Edm.Parsers.EdmBaseParser.AllocateExce lWorkshe
    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" <anonymous@discussions.microsoft.com> wrote in
    message
    >news:02e101c3ac55$4a097fc0$a001280a@phx.gbl...
    >> 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 Guest

  5. #4

    Default Re: Security Error When calling assembly.CreateInstance

    Ram,

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

    Roman
    Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139