Click here to Skip to main content
13,055,852 members (48,815 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am developing a web application in visual studio 2010 with target framework - 3.5 I am using a dll (developed by another team) in which i get an error for following code :

string strName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;

i checked and found that System.Reflection.Assembly.GetEntryAssembly() is returning null and also searched about that and found on msdn that GetEntryAssembly() may return null, when it is called from any unmanaged code.

When I am calling from my web application, it is returning null and when I call from any windows application, it works fine,i.e. it gets the entry assembly name (the assembly from which the execution has started). Why it is returning null in Web application? i can't understand. I also tried to change the output type of my web project to Class Library, from the project properties in visual studio, but the dropdown for output type, is disabled and i can't change the output type of the project. Please help me if any solutions exists for this problem.

thanks in advance

Amit Shahani
Posted 13-Feb-13 23:22pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The GetEntryAssembly method can return null when a managed assembly has been loaded from an unmanaged application. For example, if an unmanaged application creates an instance of a COM component written in C#, a call to the GetEntryAssembly method from the C# component returns null, because the entry point for the process was unmanaged code rather than a managed assembly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100