本文整理汇总了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");
}
}
示例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);
}
示例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);
}
示例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) {
}
}