7

デフォルトのAssemblyInfo.csは次のようになります。

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Foobar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Foobar")]
[assembly: AssemblyCopyright("Copyright ©  2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e8cd5d7d-5fba-4fe1-a753-f0cc6e052bf2")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

これのうち本当に必要なものは何ですか?たとえば、GuidとComVisibleが必要ない場合は削除できますか、それともAssemblyTrademarkは空なので削除できますか?

4

2 に答える 2

12

これは単なるメタデータであり、それ自体は必要ありません。

ComVisibleアセンブリとGuidの COM 相互運用を行う場合にのみ必要です。その他の属性は、最終的に DLL のメタデータになります ( VersionWindows エクスプローラーのファイル プロパティ ダイアログのタブから表示できます)。

ファイルを削除すると、アプリケーションは正常にコンパイルされますが、メタデータがなく、COM が表示されません。

于 2012-09-12T14:54:46.067 に答える
3

本当に必要な属性はありません。しかし、それらを使用することをお勧めします!

[assembly: AssemblyVersion("1.0.0.0")]

AssemblyVersion は、アセンブリにバージョンを提供し、アセンブリ (StrongName) を識別するために CLR から使用されます。AssemblyFileVersion は、FileDialog の属性のみです。

[assembly: AssemblyInformationalVersion("1.0.0.0")]

できますが、好きなように他のバージョン情報があります。もう 1 つの非常に優れた属性は次のとおりです。

[assembly: SuppressIldasm]

ildasm でアセンブリを開いて IL コードを確認することは抑制されています。

アセンブリ属性については、さらに多くの記述があります。詳細については、MSDN を参照してください。

于 2012-09-12T15:03:15.613 に答える