static void WriteTypes(Stream s, Type[] aTypes, int offset) { RegistrationServices regServices = new RegistrationServices(); String name = null; Assembly asm = Assembly.GetExecutingAssembly(); string asmver = asm.ImageRuntimeVersion; foreach (Type t in aTypes) { // only registrable managed types will show up in the manifest file if (!regServices.TypeRequiresRegistration(t)) { throw Fx.AssertAndThrow("User defined types must be registrable"); } String strClsId = "{" + Marshal.GenerateGuidForType(t).ToString().ToUpperInvariant() + "}"; name = t.FullName; // this type is a com imported type or Record if (regServices.TypeRepresentsComType(t) || t.IsValueType) { WriteUTFChars(s, "<clrSurrogate" + Environment.NewLine, offset); // attribute clsid WriteUTFChars(s, " clsid=\"" + strClsId + "\"" + Environment.NewLine, offset); // attribute class WriteUTFChars(s, " name=\"" + name + "\"" + Environment.NewLine, offset); // clr version WriteUTFChars(s, " runtimeVersion=\"" + asmver + "\">" + Environment.NewLine, offset); WriteUTFChars(s, "</clrSurrogate>" + Environment.NewLine, offset); } } }
private static void WriteTypes(Stream s, Type[] aTypes, int offset) { RegistrationServices services = new RegistrationServices(); string fullName = null; string imageRuntimeVersion = Assembly.GetExecutingAssembly().ImageRuntimeVersion; foreach (Type type in aTypes) { if (!services.TypeRequiresRegistration(type)) { throw Fx.AssertAndThrow("User defined types must be registrable"); } string str3 = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpperInvariant() + "}"; fullName = type.FullName; if (services.TypeRepresentsComType(type) || type.IsValueType) { WriteUTFChars(s, "<clrSurrogate" + Environment.NewLine, offset); WriteUTFChars(s, " clsid=\"" + str3 + "\"" + Environment.NewLine, offset); WriteUTFChars(s, " name=\"" + fullName + "\"" + Environment.NewLine, offset); WriteUTFChars(s, " runtimeVersion=\"" + imageRuntimeVersion + "\">" + Environment.NewLine, offset); WriteUTFChars(s, "</clrSurrogate>" + Environment.NewLine, offset); } } }