As far as I know, what you want is not supported. If you have an open constructor without parameters, anyone can create your class.
Now this does not mean that you cannot get what you want - it will be a little more work. You may have an βinitializedβ flag in the class that is internal (only classes in your assembly can access it). A factory will be used to instantiate the proxy and set the initialized flag to true. Only the factory flag will set this flag. Each public method in your class can perform a check to make sure that the "initialized" flag is true, and throws an exception if it is false (this means that "more work" is coming - you will have to manually add this check to each method). New instances cannot set the initialization flag due to its scope.
This will not prevent someone from updating one of your classes, but at least will not allow them to use it. As for serialization, you probably want to have some data classes and serialize them instead of your proxied classes.
source share