Using the Web Application version number from an assembly (ASP.NET/C#)

后端 未结 12 1007
我寻月下人不归
我寻月下人不归 2020-12-07 18:39

How do I obtain the version number of the calling web application in a referenced assembly?

I\'ve tried using System.Reflection.Assembly.GetCallingAssembly().GetName

12条回答
  •  佛祖请我去吃肉
    2020-12-07 19:07

    If you are looking for this from a web control, one hack is to find the type of the code-behind Page (ie. the class that inherits from System.Web.UI.Page). This is normally in the consumer's web assembly.

    Type current, last;
    current = Page.GetType();
    do
    {
        last = current;
        current = current.BaseType;
    } while (current != null && current != typeof(System.Web.UI.Page));
    return last;
    

    I hope there is a better way.

提交回复
热议问题