def test_load_typelib(): for x in [ dlrcomlib_guid, Activator.CreateInstance( Type.GetTypeFromProgID("DlrComLibrary.ParamsInRetval")) ]: lib = clr.LoadTypeLibrary(x) #ComTypeLibInfo Members AreEqual(lib.Guid, dlrcomlib_guid) AreEqual(lib.Name, "DlrComLibraryLib") AreEqual(lib.VersionMajor, 1) AreEqual(lib.VersionMinor, 0) Assert("DlrComLibraryLib" in dir(lib)) #ComTypeLibDesc Members dlrComLib = lib.DlrComLibraryLib Assert("DlrComServer" in dir(lib.DlrComLibraryLib)) Assert("IDlrComServer" not in dir(lib.DlrComLibraryLib)) #ComTypeClassDesc Members dlrComServer = lib.DlrComLibraryLib.DlrComServer AreEqual(dlrComServer.TypeLib, lib.DlrComLibraryLib) AreEqual(dlrComServer.TypeName, "DlrComServer") AreEqual(str(dlrComServer.Kind), "Class") #Create an instance of the class and access members. obj = dlrComServer.CreateInstance() Assert("__ComObject" in str(obj.__class__)) AreEqual(12345, obj.SumArgs(1, 2, 3, 4, 5)) #Complete the circle back to the lib AreEqual(clr.LoadTypeLibrary(obj).Guid, lib.Guid)
def CreateAgentServer(): import clr from System import Guid typelib = clr.LoadTypeLibrary(Guid("A7B93C73-7B81-11D0-AC5F-00C04FD97575")) return typelib.AgentServerObjects.AgentServer()