Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Problem in loading types from assembly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JJ - 24 Jul 2006 13:41 GMT
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
JJ - 24 Jul 2006 14:26 GMT
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.

> Hi all,
>
[quoted text clipped - 44 lines]
> Regards,
> JJ
Peter Ritchie [MVP] - 24 Jul 2006 14:57 GMT
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...

Signature

http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#

> Hi all,
>
[quoted text clipped - 39 lines]
> System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
> System.Reflection.Assembly.GetTypes()
JJ - 24 Jul 2006 15:10 GMT
Thanks, Peter.

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

Regards,
JJ

Peter wrote:
> 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
[quoted text clipped - 52 lines]
> > System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
> > System.Reflection.Assembly.GetTypes()
JJ - 25 Jul 2006 06:38 GMT
I tried configuring the .NET framework security configuration -- still
did not work.

Regards,
JJ

> Thanks, Peter.
>
[quoted text clipped - 61 lines]
> > > System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
> > > System.Reflection.Assembly.GetTypes()
JJ - 25 Jul 2006 06:56 GMT
Resolved.

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

JJ

> I tried configuring the .NET framework security configuration -- still
> did not work.
[quoted text clipped - 67 lines]
> > > > System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
> > > > System.Reflection.Assembly.GetTypes()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.