I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties t
@rally25rs, although the post is more than two years old it's still ranked high (views/google etc.) so I thought I'd add my 2 cents.. I've had the same problem and eventually chose this solution: UnityContainer and internal constructor. This is meant as a comment but I can't post comments just yet.
You've probably seen and know this already, still it might be of use for anyone else viewing: The InternalsVisibleTo()
attribute should never have worked - that's because Unity isn't calling your classes directly. Instead, it's using reflection and inspecting the Type
. Of course, the Type
isn't changed as a result of the attribute being there. To "enjoy" the benefits of internals visible etc. on the receiving side, you have to explicitly call the internal c'tor (or property).