ASP.NET MVC: How to obtain assembly information from HtmlHelper instance?

后端 未结 3 1704
耶瑟儿~
耶瑟儿~ 2021-02-20 04:50

I have an HtmlHelper extension method in an assembly separate from my MVC application assembly. Within the extension method I would like to get the version number of the MVC app

3条回答
  •  鱼传尺愫
    2021-02-20 05:42

    Just search for the assembly which should be the source for your version number

    AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name.Equals("MyDll")).First().GetName().Version.ToString();
    

提交回复
热议问题