Does spring.net support recurse subcategories?
When starting spring.net framework for asp.net application, the component that registers all objects in the IoC container recurses all subdirectories that are referenced in web.config?
eg.
<spring>
<context>
<resource uri="~/bin/ClientService/ClientService.config"/>
<resource uri="~/MCFModule.config"/>
</context>
</spring>
I believe the answer is yes, looking at the debug output (tracer).
The problem I see is that when trying to instantiate in the "\ bin \ clientservice" directory, it fails with an error message even though the DLL exists in a subdirectory;
'Could not load file or assembly' log4net, Version = 1.2.10.0, Culture = neutral, PublicKeyToken = 1b44e1d426115821 'or one of its dependencies. The system cannot find the file specified.
Does anyone have any ideas?
Greetings
Ollie
a source to share
You also have the ability to programmatically handle assembly load failures using an
AppDomain.AssemblyResolve
event on the AppDomain class.
You can, for example, scan all subdirectories looking for the assembly you are interested in.
a source to share
When Spring.NET tries to resolve a reference in its config file, it will use the same rules as the .NET loader assembly. So maybe you can try adding the correct log4net build reference in the bin folder.
EDIT: If you want Spring.NET to detect assemblies in non-standard locations, you can use the <assemblyBinding> element to specify the location:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="someObject" type="log4net.Util.AppenderAttachedImpl, log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
</objects>
</spring>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net"
publicKeyToken="1b44e1d426115821"
culture="neutral" />
<codeBase version="1.2.10.0
href="file:///c:/some_special_location/log4net.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
And then you can ask the container to instantiate the object:
var someObject = ContextRegistry.GetContext().GetObject("someObject");
a source to share