How create an instance of an abstract class with internal members using remoting / proxy?
I was playing around with Microsoft Entity framework 4 and at some point i want to create a fake instance of ObjectStateEntry using a proxy or FormatterServices and faced with the issues that follow:
- The class has internal abstract members therefore creating a proxy ends up with type having not-implemented members. Therefore, throws exception during
CreateInstance
. - Can't use
FormatterServices.GetUinitializedDat开发者_运维百科a
as it is an abstract class.
Would love to know, if are there any other option available ?
Here I wrote down my answer as soon as I saw your question title How create an instance of an abstract class
, the answer is No, you can't create an instance of an abstract class.
Have you tried any mocking framework such as Rhino Mocks
精彩评论