3

以下のようなファイルがありAssemblyInfo.csます。AssemblyVersion の文字列を定義したいと思います。

string version = "1.2.0.0";  

しかし、次のようなエラーが表示されます。

名前空間にメンバーを直接含めることはできません

どうすればいいですか?

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

// Setting ComVisible to false makes the types in this assembly not visible  to COM components
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("24f53cr8-552b-40d3-cds1-13e310ds6c3f")]

[assembly: AssemblyCopyright("1/10/2013")]

#if (DEVELOPMENT)
[assembly: AssemblyProduct("ShellDev")]
[assembly: AssemblyConfiguration("DEVELOPMENT")]
[assembly: AssemblyTitle("MMD Smart Client - Development Version")]
[assembly: AssemblyVersion("1.2.0.0")]
#endif

#if (RELEASE)
[assembly: AssemblyProduct("Shell")]
[assembly: AssemblyTitle("MMD Smart Client")]
[assembly: AssemblyVersion("1.2.0.0")]
#endif
4

1 に答える 1

10

C# にはグローバル変数はありません。文字列を静的クラスに入れます。

internal static class Version
{
   public const string VersionString = "1.2.0.0"; 
}

そして、次のように使用します。

[assembly: AssemblyVersion(Version.VersionString)]
于 2013-01-17T17:42:53.850 に答える