Creating an instance of an internal class using Spring.Net is a little tricky. I know that, you can achieve this by adding an InternalsVisibleTo attribute to your assembly. However, the following solution also works as desired.
Say, you have an namespace named SampleClasses that contains the a public interface named 'IPublicInterface' and also an internal class named 'InternalClass' that implements the IPublicInterface interface and looks like the following -
And also, you have an xml configuration file named 'SampleClasses.Spring.xml' containing your object definition for InternalClass and looks like the following one -
Now, you need to make sure the following are true -
1. 'SampleClasses.Spring.xml is compiled as an embedded resource with the assembly that holds the InternalClass class and also in the same namespace. To ensure this, right click the XML file, select Properties and Select Embedded Resource in the Build Action.
2. In your App.Config (or Web.Config, for web applications), add the following XML declarations to add the embedded XML file -
Now, that you have everything ready you can simply write the following code segment to access create an instance of the internal class and hold it through the IPublicInterface as shown below-
So, you see that its simple way to create an instance of an internal type using Spring.Net given that the internal type is the type of a public Interface. If this assumption is not true, then probably you are not following the best OO designs, where you need to create instances of types that are only supposed to be internal to a namespace.
Wish it helps some of you. Send me a comment if you need the full source code and project.