private static int AddRef(IntPtr @this) { #if MAP_EX_TO_HR try { #endif ManagedToNativeWrapper thisObject = GetObject(@this); lock (thisObject) { return ++thisObject.refCount; } #if MAP_EX_TO_HR } catch { return 0; } #endif }