Problem in loading types from assembly

J

JJ

Hi all,

I am having problem in loading types from an assembly using reflection.
I am using:

1. Windows Server 2003 64-Bit
2. Microsoft .NET Framework 1.1
3. IIS 6.0

My application is an ASP.NET web application and this application can
be started with providing log-in credentials through a logon page.
These credentials are nothing but the users organizational network
userid/password. The application will impersonate the user by examining
the Active Directory, and then proceed. I am using the windows
authentication mode -- following are the entries of my web.config file:
<authentication mode="Windows"/>
<identity impersonate="true"/>
In IIS, I am using both "Integrated Windows Authentication" and
"Anonymous Access".
Also, my application pool uses "Local System" identity.

Now, after calling the Impersonate() method of the WindowsIdentity
class, I am loading an assembly (the assembly is NOT stored in GAC)
like:

Assembly a = Assembly.LoadFrom("myassembly.dll");
IMyType vType = (IMyType)Activator.CreateInstance(a.GetType("mytype",
false, true));

Now, when I run this application, depending on the user, two different
things happen:

Scenario 1: The userid that I pass in the logon screen is the userid of
a user who is a member of the administrators group of the web server.
Result: Works fine.

Scenario 2: The userid that I pass in the logon screen is the userid of
a user who is NOT a member of the administrators group of the web
server.
Result: Getting the following error:
One or more of the types in the assembly unable to load.
System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
System.Reflection.Assembly.GetTypes()

Can anyone suggest any remedy please?

Regards,
JJ
 
J

JJ

Little correction--the error actually comes from the line:
foreach(System.Type t in a.GetTypes()) {
Response.Write(string.Format("<br>Type {0}:{1}",++count,t.Name));
}

which I am using for debugging.
 
G

Guest

You generally want to use a complete path with LoadFrom. While the current
directory is usually C:\Windows\System (or %SystemRoot%\system32) there's no
real guarentee that will be the case when you code is executed.

Ideally you should either place the full path to your assembly in a config
file, or the directory to the assembly in the config file. That makes life
so much easier. Ignore this if you're just using the hard-coded path as an
example...
 
J

JJ

Thanks, Peter.

The "myassembly.dll" is a dummy name, and I am actually using the
complete path.

Regards,
JJ
 
J

JJ

I tried configuring the .NET framework security configuration -- still
did not work.

Regards,
JJ
 
J

JJ

Resolved.

Checked the security level of
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"
and done.

JJ
 

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

Top