Security Error When calling assembly.CreateInstance

R

Roman

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.
 
R

Roman

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!!!

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.


.
 
G

Guest

Ram,

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

Roman
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,077
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top