/// <summary> /// Eager initialization code called from LibraryInitializer. /// </summary> internal static void Initialize() { UseDynamicInterop = false; CCWLookupMap.InitializeStatics(); ContextEntry.ContextEntryManager.InitializeStatics(); ComObjectCache.InitializeStatics(); }
static McgModuleManager() { UseDynamicInterop = false; CCWLookupMap.InitializeStatics(); ContextEntry.ContextEntryManager.InitializeStatics(); ComObjectCache.InitializeStatics(); }
static McgModuleManager() { CCWLookupMap.InitializeStatics(); ContextEntry.ContextEntryManager.InitializeStatics(); ComObjectCache.InitializeStatics(); const int DefaultSize = 101; // small prime number to avoid resizing in start up code s_runtimeTypeHandleToMcgInterfaceInfoMap = new Collections.Generic.Internal.Dictionary <RuntimeTypeHandle, McgInterfaceInfo>(DefaultSize, new RuntimeTypeHandleComparer(), /* sync = */ true); s_runtimeTypeHandleToCCWTemplateInfoMap = new Collections.Generic.Internal.Dictionary <RuntimeTypeHandle, CCWTemplateInfo>(DefaultSize, new RuntimeTypeHandleComparer(), /* sync = */ true); }
private static unsafe IntPtr ManagedObjectToComInterfaceInternal(Object obj, ref Guid iid, RuntimeTypeHandle interfaceType) { if (obj == null) { return(default(IntPtr)); } // // Look up ComCallableObject from the cache // If couldn't find one, create a new one // ComCallableObject ccw = null; try { // // Either return existing one or create a new one // In either case, the returned CCW is addref-ed to avoid race condition // IntPtr dummy; ccw = CCWLookupMap.GetOrCreateCCW(obj, interfaceType, out dummy); Debug.Assert(ccw != null); return(ccw.GetComInterfaceForIID(ref iid, interfaceType)); } finally { // // Free the extra ref count added by GetOrCreateCCW (to protect the CCW from being collected) // if (ccw != null) { ccw.Release(); } } }