当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyBuilder.DefineVersionInfoResource方法代码示例

本文整理汇总了C#中System.Reflection.Emit.AssemblyBuilder.DefineVersionInfoResource方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.DefineVersionInfoResource方法的具体用法?C# AssemblyBuilder.DefineVersionInfoResource怎么用?C# AssemblyBuilder.DefineVersionInfoResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Emit.AssemblyBuilder的用法示例。


在下文中一共展示了AssemblyBuilder.DefineVersionInfoResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefineVersionInfoResource

	[Test] // DefineVersionInfoResource (String, String, String, String, String)
	public void TestDefineVersionInfoResource2_Culture_NotSupported ()
	{
		AssemblyName aname = new AssemblyName ();
		aname.CultureInfo = new CultureInfo ("nl-BE");
		aname.Name = "lib";
		aname.Version = new Version (3, 5, 7);

		AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
			aname, AssemblyBuilderAccess.RunAndSave,
			tempDir);

		// AssemblyCulture
		Type attrType = typeof (AssemblyCultureAttribute);
		ConstructorInfo ci = attrType.GetConstructor (new Type [] { typeof (String) });
		CustomAttributeBuilder cab = new CustomAttributeBuilder (
			ci, new object [1] { "doesnotexist" });
		ab.SetCustomAttribute (cab);

		ab.DefineVersionInfoResource ("A", "1.0", "C", "D", "E");

		try {
			ab.Save ("lib.dll");
			Assert.Fail ("#A1");
		} catch (ArgumentException ex) {
			// Culture name doesnotexist is not supported
			Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
			Assert.IsNull (ex.InnerException, "#A3");
			Assert.IsNotNull (ex.Message, "#A4");
			Assert.IsTrue (ex.Message.IndexOf ("doesnotexist") != -1, "#A5");
			Assert.AreEqual ("name", ex.ParamName, "#A6");
		}

		ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname,
			AssemblyBuilderAccess.RunAndSave, tempDir);

		// AssemblyCulture
		attrType = typeof (AssemblyCultureAttribute);
		ci = attrType.GetConstructor (new Type [] { typeof (String) });
		cab = new CustomAttributeBuilder (ci, new object [1] { "neutral" });
		ab.SetCustomAttribute (cab);

		ab.DefineVersionInfoResource ("A", "1.0", "C", "D", "E");

		try {
			ab.Save ("lib.dll");
			Assert.Fail ("#B1");
		} catch (ArgumentException ex) {
			// Culture name neutral is not supported
			Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
			Assert.IsNull (ex.InnerException, "#B3");
			Assert.IsNotNull (ex.Message, "#B4");
			Assert.IsTrue (ex.Message.IndexOf ("neutral") != -1, "#B5");
			Assert.AreEqual ("name", ex.ParamName, "#B6");
		}
	}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:56,代码来源:AssemblyBuilderTest.cs

示例2: SetVersionInformation

 private static void SetVersionInformation(AssemblyBuilder asmBldr, object typeLib, AssemblyName asmName)
 {
     string strName = null;
     string strDocString = null;
     int dwHelpContext = 0;
     string strHelpFile = null;
     ((ITypeLib) typeLib).GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile);
     string product = string.Format(CultureInfo.InvariantCulture, Environment.GetResourceString("TypeLibConverter_ImportedTypeLibProductName"), new object[] { strName });
     asmBldr.DefineVersionInfoResource(product, asmName.Version.ToString(), null, null, null);
     SetTypeLibVersionAttribute(asmBldr, typeLib);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:TypeLibConverter.cs

示例3: SetVersionInformation

        [System.Security.SecurityCritical]  // auto-generated
        private static void SetVersionInformation(AssemblyBuilder asmBldr, Object typeLib, AssemblyName asmName)
        {
            // Extract the name of the typelib.
            String strTypeLibName = null;
            String strDocString = null;
            int dwHelpContext = 0;
            String strHelpFile = null;
            ITypeLib pTLB = (ITypeLib)typeLib;
            pTLB.GetDocumentation(-1, out strTypeLibName, out strDocString, out dwHelpContext, out strHelpFile);

            // Generate the product name string from the named of the typelib.
            String strProductName = String.Format(CultureInfo.InvariantCulture, Environment.GetResourceString("TypeLibConverter_ImportedTypeLibProductName"), strTypeLibName);

            // Set the OS version information.
            asmBldr.DefineVersionInfoResource(strProductName, asmName.Version.ToString(), null, null, null);

            // Set the TypeLibVersion attribute
            SetTypeLibVersionAttribute(asmBldr, typeLib);
        }
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:20,代码来源:TypeLibConverter.cs

示例4: DefineVersionInfoResource

	[Test] // DefineVersionInfoResource (String, String, String, String, String)
	public void TestDefineVersionInfoResource2_Culture_NotSupported ()
	{
		AssemblyName aname = new AssemblyName ();
		aname.CultureInfo = new CultureInfo ("nl-BE");
		aname.Name = "lib";
		aname.Version = new Version (3, 5, 7);

		AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
			aname, AssemblyBuilderAccess.RunAndSave,
			tempDir);

		// AssemblyCulture
		Type attrType = typeof (AssemblyCultureAttribute);
		ConstructorInfo ci = attrType.GetConstructor (new Type [] { typeof (String) });
		CustomAttributeBuilder cab = new CustomAttributeBuilder (
			ci, new object [1] { "doesnotexist" });
		ab.SetCustomAttribute (cab);

		ab.DefineVersionInfoResource ("A", "1.0", "C", "D", "E");

		try {
			ab.Save ("lib.dll");
			Assert.Fail ("#A1");
		} catch (CultureNotFoundException ex) {
		}

		ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname,
			AssemblyBuilderAccess.RunAndSave, tempDir);

		// AssemblyCulture
		attrType = typeof (AssemblyCultureAttribute);
		ci = attrType.GetConstructor (new Type [] { typeof (String) });
		cab = new CustomAttributeBuilder (ci, new object [1] { "neutral" });
		ab.SetCustomAttribute (cab);

		ab.DefineVersionInfoResource ("A", "1.0", "C", "D", "E");

		try {
			ab.Save ("lib.dll");
			Assert.Fail ("#B1");
		} catch (CultureNotFoundException ex) {
		}
	}
开发者ID:Profit0004,项目名称:mono,代码行数:44,代码来源:AssemblyBuilderTest.cs


注:本文中的System.Reflection.Emit.AssemblyBuilder.DefineVersionInfoResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。