System.Runtime.InteropServices.ExtensibleClassFactory.RegisterObjectCreationCallback C# (CSharp) Method

RegisterObjectCreationCallback() public static method

public static RegisterObjectCreationCallback ( ObjectCreationDelegate callback ) : void
callback ObjectCreationDelegate
return void
		public static void RegisterObjectCreationCallback (ObjectCreationDelegate callback) {
			int i = 1;
			StackTrace trace = new StackTrace (false);
			while (i < trace.FrameCount) {
				StackFrame frame = trace.GetFrame (i);
				MethodBase m = frame.GetMethod ();
				if (m.MemberType == MemberTypes.Constructor && m.IsStatic) {
					hashtable.Add (m.DeclaringType, callback);
					return;
				}
				i++;
			}
			throw new System.InvalidOperationException (
				"RegisterObjectCreationCallback must be called from .cctor of class derived from ComImport type.");
		}
	}