本文介绍了帮助强命名ASP.NET 2.0 Web应用程序程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我继承了一个使用.net 2开发的网站-我正在编写一个应用程序运行状况页,以显示该网站dll的程序集版本.我修改了AssemblyInfo.cs并添加了以下内容: [程序集: AssemblyTitle ( 我的应用" )]] [assembly: 组装说明 ( " )]] 如果 调试 [assembly:AssemblyConfiguration( " DEBUG")]] #else [程序集: AssemblyConfiguration ( " RELEASE" )] # endif [程序集: AssemblyCompany ( 我的公司" )] [组装y: AssemblyProduct ( 我的产品" )]] [程序集: AssemblyCopyright ( (C)2009" )]] [assembly: AssemblyVersion ( "1.0.4.5" )]] [程序集: AssemblyFileVersion ( ""1.0.4.5" )] [汇编: AssemblyKeyFile ( @" D:\ PathTo \ My.snk" )] 但是我在运行代码时:公开 局部 类 ApplicationHealth PageBase { 受保护的 无效 Page_Load( 对象 发送者, EventArgs e) { 组装 []程序集= AppDomain .CurrentDomain.GetAssemblies(); StringBuilder sb = 新 StringBuilder (); foreach ( 装配体 a in 程序集) { ///忽略框架程序集的 字符串 ExcludedNames =( "SystemMicrosoft.JScriptVJSharpCodeProviderCppCodeProviderWebDev.WebHostmscorlib" ); 如果 ((a.GetName().Name.ToString() .IndexOf( 系统" )< 0)&& (a.GetName().Name.ToString().IndexOf( "Microsoft" )< 0)&& (ExcludedNames.IndexOf(a.GetName().Name.ToString())< 0)&& (a.GetName().Version.ToString()!= "0.0.0.0" ))) { 尝试 { sb.Append( < li>"" + a.GetName ().Version.ToString()); AssemblyInformationalVersionAttribute [] infoversion =( AssemblyInformationalVersionAttribute [ ])a.GetCustomAttributes( 类型 ( AssemblyInformationalVersionAttribute ), false ); 如果 (infoversion.Length == 1) { sb.Append( < li>" + infoversion [0] .InformationalVersion.ToString()); } sb.Append( " + a.GetName().Name.ToString()); } 捕获 {} } } Response.Write(sb.ToString()); } } 我收到错误编译器错误消息: CS1577:程序集生成失败-引用程序集' MyNameSpace '的名字不强. 我想-除非有一种更好的方式来获取程序集版本信息(极有可能) !)-我需要知道如何强命名MyNameSpace.dll. 非常感谢您的帮助. 解决方案 I've inherited a web site developed using .net 2 - I'm writing an application health page to display the assembly version of the web site dll. I amended the AssemblyInfo.cs and added the following:[assembly:AssemblyTitle("My App")][assembly: AssemblyDescription("")]if DEBUG[assembly: AssemblyConfiguration("DEBUG")]#else[assembly: AssemblyConfiguration("RELEASE")]#endif[assembly: AssemblyCompany("My Company")][assembly: AssemblyProduct("My Product")][assembly: AssemblyCopyright("(C) 2009")][assembly: AssemblyVersion("1.0.4.5")][assembly: AssemblyFileVersion("1.0.4.5")][assembly: AssemblyKeyFile(@"D:\PathTo\My.snk")]however when I run the code:public partial class ApplicationHealth : MyNameSpace.PageBase{protected void Page_Load(object sender, EventArgs e){Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();StringBuilder sb = new StringBuilder(); foreach (Assembly a in assemblies){//Ignore the Framework Assembly'sstring ExcludedNames = ("SystemMicrosoft.JScriptVJSharpCodeProviderCppCodeProviderWebDev.WebHostmscorlib");if ((a.GetName().Name.ToString().IndexOf("System") < 0) && (a.GetName().Name.ToString().IndexOf("Microsoft") < 0) && (ExcludedNames.IndexOf(a.GetName().Name.ToString()) < 0) && (a.GetName().Version.ToString() != "0.0.0.0")){try{sb.Append( "<li>" + a.GetName().Version.ToString());AssemblyInformationalVersionAttribute[] infoversion = (AssemblyInformationalVersionAttribute[])a.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);if (infoversion.Length == 1){sb.Append( "<li>" + infoversion[0].InformationalVersion.ToString());}sb.Append( " " + a.GetName().Name.ToString() );}catch{}}}Response.Write(sb.ToString());}} I received the error Compiler Error Message: CS1577: Assembly generation failed -- Referenced assembly 'MyNameSpace' does not have a strong name.I think - unless there is a far better way of getting the Assembly Version Information (highly likely!) - I need to know how to Strong Name the MyNameSpace.dll.Any help very much appreciated. 解决方案 这篇关于帮助强命名ASP.NET 2.0 Web应用程序程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-25 01:41