Just having Foo is not possible. You can enter the facade / proxy object and pass it to the constructor code, so you can connect everything:
public class FooFacade { private Foo foo; public void SetFoo(Foo f) { foo = f; }
Then you can use this facade:
FooFacade ff = new FooFacade(); Foo f = new Foo(ff); ff.SetFoo(f);
Of course, this is not what you wanted in the first place. The disadvantage of this attempt is that the state of the object is limited to public representation.
With reflection, just for completeness:
// create an uninitialized object of type Foo, does not call constructor: var f = (Foo)FormatterServices.GetUninitializedObject(typeof(Foo)); // get field: var stateField = typeof(Foo).GetField("_state", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); // set value to instance itself, invoke on f: stateField.SetValue(f, f);
source share