How can I prevent a base constructor from being called by an inheritor in C#?

There is a way to create an object without calling any instance constructors.

Before you proceed, be very sure you want to do it this way. 99% of the time this is the wrong solution.

This is how you do it:

FormatterServices.GetUninitializedObject(typeof(MyClass));

Call it in place of the object’s constructor. It will create and return you an instance without calling any constructors or field initializers.

When you deserialize an object in WCF, it uses this method to create the object. When this happens, constructors and even field initializers are not run.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)