dimanche 24 janvier 2016

GetEntryAssembly doesn't appear to work when the entry assembly is ASP.NET

First, I do not believe this is a dupe of these:

GetEntryAssembly for web applications

Get entry assembly from ASP.NET application

I have an ASP.NET WebForms app that references a class library. When I call Assembly.GetEntryAssembly() from within the class library while it's referenced by the ASP.NET app, it returns null. However, when I call that same code while the class library is referenced by a console app, it returns the console app assembly.

This answer perhaps sheds light on why Assembly.GetEntryAssembly() behaves differently with ASP.NET:

Why do ASP.NET resolve assembly references differently?

Still, I'd like to be able to get the ASP.NET assembly as if it were a Windows application (console, WPF, WinForms, etc). Is there any way to allow my class library to know about the ASP.NET assembly without adding any ASP.NET references?





Aucun commentaire:

Enregistrer un commentaire