Pablote Pablote - 10 months ago 64
ASP.NET (C#) Question

Get web application assembly name, regardless of current executing assembly

Is is possible to get the assembly name of an ASP.NET web application, from a referenced assembly??

Assembly.GetEntryAssembly worked fine in desktop and console apps but it seems to be always null in web apps, and GetExecuting\GetCallingAssebly return my referenced assembly, not the one from the web app.

Long explanation:

I wrote a custom Settings Provider, that instead of reading configuration from the app config file, it gets the settings from a centralized configuration service.

The custom provider is in a separate assembly so it can be used by the different applications.

The ApplicationName property needs to be overriden with the app assembly name.

The way to use the provider is though a .net custom attribute, so I can't send any params to it.

Since non of the Assembly.Get*Assembly methods seem to work, the only thing a I can think of is requiring an appSetting with the app name for web apps, but I'm not really happy with that. Any help with this is appreciated, thanks!

Answer Source


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download