internal static AssemblyName GetAssemblyNameFromTypelib(object typeLib, string asmFileName, byte[] publicKey, StrongNameKeyPair keyPair, Version asmVersion, AssemblyNameFlags asmNameFlags) { string text = null; string text2 = null; int num = 0; string text3 = null; ITypeLib typeLib2 = (ITypeLib)typeLib; typeLib2.GetDocumentation(-1, out text, out text2, out num, out text3); if (asmFileName == null) { asmFileName = text; } else { string fileName = Path.GetFileName(asmFileName); string extension = Path.GetExtension(asmFileName); if (!".dll".Equals(extension, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileExtension")); } asmFileName = fileName.Substring(0, fileName.Length - ".dll".Length); } if (asmVersion == null) { int major; int minor; Marshal.GetTypeLibVersion(typeLib2, out major, out minor); asmVersion = new Version(major, minor, 0, 0); } AssemblyName assemblyName = new AssemblyName(); assemblyName.Init(asmFileName, publicKey, null, asmVersion, null, AssemblyHashAlgorithm.None, AssemblyVersionCompatibility.SameMachine, null, asmNameFlags, keyPair); return(assemblyName); }
private static void SetTypeLibVersionAttribute(AssemblyBuilder asmBldr, object typeLib) { int num; int num2; Type[] types = new Type[] { typeof(int), typeof(int) }; ConstructorInfo constructor = typeof(TypeLibVersionAttribute).GetConstructor(types); Marshal.GetTypeLibVersion((ITypeLib)typeLib, out num, out num2); object[] constructorArgs = new object[] { num, num2 }; CustomAttributeBuilder customBuilder = new CustomAttributeBuilder(constructor, constructorArgs); asmBldr.SetCustomAttribute(customBuilder); }
internal static AssemblyName GetAssemblyNameFromTypelib(object typeLib, string asmFileName, byte[] publicKey, StrongNameKeyPair keyPair, Version asmVersion, AssemblyNameFlags asmNameFlags) { string strName = (string)null; string strDocString = (string)null; int dwHelpContext = 0; string strHelpFile = (string)null; ITypeLib typeLibrary = (ITypeLib)typeLib; typeLibrary.GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile); if (asmFileName == null) { asmFileName = strName; } else { string fileName = Path.GetFileName(asmFileName); if (!".dll".Equals(Path.GetExtension(asmFileName), StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileExtension")); } asmFileName = fileName.Substring(0, fileName.Length - ".dll".Length); } if (asmVersion == (Version)null) { int major; int minor; Marshal.GetTypeLibVersion(typeLibrary, out major, out minor); asmVersion = new Version(major, minor, 0, 0); } AssemblyName assemblyName = new AssemblyName(); string name = asmFileName; byte[] publicKey1 = publicKey; // ISSUE: variable of the null type __Null local1 = null; Version version = asmVersion; // ISSUE: variable of the null type __Null local2 = null; int num1 = 0; int num2 = 1; // ISSUE: variable of the null type __Null local3 = null; int num3 = (int)asmNameFlags; StrongNameKeyPair keyPair1 = keyPair; assemblyName.Init(name, publicKey1, (byte[])local1, version, (CultureInfo)local2, (AssemblyHashAlgorithm)num1, (AssemblyVersionCompatibility)num2, (string)local3, (AssemblyNameFlags)num3, keyPair1); return(assemblyName); }
private static void SetTypeLibVersionAttribute(AssemblyBuilder asmBldr, object typeLib) { ConstructorInfo constructor = typeof(TypeLibVersionAttribute).GetConstructor(new Type[2] { typeof(int), typeof(int) }); int major; int minor; Marshal.GetTypeLibVersion((ITypeLib)typeLib, out major, out minor); object[] constructorArgs = new object[2] { (object)major, (object)minor }; CustomAttributeBuilder customBuilder = new CustomAttributeBuilder(constructor, constructorArgs); asmBldr.SetCustomAttribute(customBuilder); }
[System.Security.SecurityCritical] // auto-generated private static void SetTypeLibVersionAttribute(AssemblyBuilder asmBldr, Object typeLib) { Type [] aConsParams = new Type[2] { typeof(int), typeof(int) }; ConstructorInfo TypeLibVerCons = typeof(TypeLibVersionAttribute).GetConstructor(aConsParams); // Get the typelib version int major; int minor; Marshal.GetTypeLibVersion((ITypeLib)typeLib, out major, out minor); // Create an instance of the custom attribute builder. Object[] aArgs = new Object[2] { major, minor }; CustomAttributeBuilder TypeLibVerBuilder = new CustomAttributeBuilder(TypeLibVerCons, aArgs); // Set the attribute on the assembly builder. asmBldr.SetCustomAttribute(TypeLibVerBuilder); }
[System.Security.SecurityCritical] // auto-generated internal static AssemblyName GetAssemblyNameFromTypelib(Object typeLib, String asmFileName, byte[] publicKey, StrongNameKeyPair keyPair, Version asmVersion, AssemblyNameFlags asmNameFlags) { // 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); // Retrieve the name to use for the assembly. if (asmFileName == null) { asmFileName = strTypeLibName; } else { Contract.Assert((asmFileName != null) && (asmFileName.Length > 0), "The assembly file name cannot be an empty string!"); String strFileNameNoPath = Path.GetFileName(asmFileName); String strExtension = Path.GetExtension(asmFileName); // Validate that the extension is valid. bool bExtensionValid = ".dll".Equals(strExtension, StringComparison.OrdinalIgnoreCase); // If the extension is not valid then tell the user and quit. if (!bExtensionValid) { throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileExtension")); } // The assembly cannot contain the path nor the extension. asmFileName = strFileNameNoPath.Substring(0, strFileNameNoPath.Length - ".dll".Length); } // If the version information was not specified, then retrieve it from the typelib. if (asmVersion == null) { int major; int minor; Marshal.GetTypeLibVersion(pTLB, out major, out minor); asmVersion = new Version(major, minor, 0, 0); } // Create the assembly name for the imported typelib's assembly. AssemblyName AsmName = new AssemblyName(); AsmName.Init( asmFileName, publicKey, null, asmVersion, null, AssemblyHashAlgorithm.None, AssemblyVersionCompatibility.SameMachine, null, asmNameFlags, keyPair); return(AsmName); }