Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 183431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:06:53+00:00 2026-05-11T15:06:53+00:00

I have created a DLL that will gather information from the AssemblyInfo.cs. In the

  • 0

I have created a DLL that will gather information from the AssemblyInfo.cs. In the class constructor I am using Reflection to get the top-most application that is running.

public class AppInfo() {     public AppInfo()     {         System.Reflection.Assembly assembly =             System.Reflection.Assembly.GetEntryAssembly();         if (assembly == null)             assembly = System.Reflection.Assembly.GetCallingAssembly();           //code to gather needed information     } } 

How this is intended to be used is if I call this from any DLL in a given application, MyApp, that lets say the name will always be ‘MyApp’. Retrieving that information is not a problem and it works great in Windows Services and Windows Applications. My question is this: How do I get the Assembly of the top-most Website?

I have found a few articles and I can get the information in the Global.asax.cs by moving the AssemblyInfo.cs for the Website out of the App_Code folder and into the root of the Website. Then by adding a compilerOption to the physical path of the AssemblyInfo.cs

<compiler language='c#;cs;csharp' extension='.cs' compilerOptions='C:\Sandbox\MyWebSite\AssemblyInfo.cs' type='Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' warningLevel='4'> 

Using that I am able to retrieve information in the AssemblyInfo.cs for the Website through System.Reflection.Assembly.GetExecutingAssembly(). Now I can overload the constructor of my AppInfo class to accept an Assembly and retrieve information that way, but if another DLL that is used by MyWebSite creates a new AppInfo() I will get the assembly information of that DLL instead of the parent Website.

I know that if I was working with Web Apps instead of Web Sites I wouldn’t have this issue, but for reasons I won’t go into I am not able to use Web Apps. Any suggestions on how I can read information from the AssemblyInfo.cs of the Website I’m running in no matter what DLL I’m in?

EDIT: I need this to work for Web Sites, Windows Apps and Windows Services

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:06:54+00:00Added an answer on May 11, 2026 at 3:06 pm

    If I understand you properly, the problem is that Assembly.GetEntryAssembly() returns null in a Website and Assembly.GetCallingAssembly() is returning the wrong thing because you’ve got a chain of calls resulting in the website not being the immediate caller. If that’s the case, you could find the ‘Entry Assembly’ using the stack trace & walking back up the calling frames. The stack will be full of references from System.Web, etc as the call will have originated from deep within IIS somewhere, but you should be able to pick out the assembly you’re interested in by grabbing the lowest frame that you can positively identify as belonging to you. Note that this is pretty hacky, but I think it’ll get you what you want…

    var trace = new StackTrace(); Assembly entryAssembly = null; foreach (var frame in trace.GetFrames()) {    var assembly = frame.GetMethod().DeclaringType.Assembly;    //check if the assembly is one you own & therefore could be your logical    //'entry assembly'. You could do this by checking the prefix of the    //Assembly Name if you use some standardised naming convention, or perhaps    //looking at the AssemblyCompanyAttribute, etc    if ('assembly is one of mine')    {       entryAssembly = assembly;    } } 

    Hopefully someone else will be able to come up with a less nasty way of doing it… but if you’re really stuck, this might help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in
I have a small issue with forms that are created from inside a DLL.
I have created a C++/CLI mixed DLL which I am using from C# Winforms
I have acquired a DLL that was created in Visual Basic from a third
This is the first time I have attempted to create a .dll, that will
I have created several DLL (.NET) libraries that are used in several projects. In
Just created a .dll file that has some methods. And I have a another
I have a .Net DLL that I created that implements a WCF client that
The problem is, I have a DLL and TLB that I created in C#.NET,
I have created an ActiveX dll using VB6 and packaged it using the Package

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.