I'm trying out the new Spring CodeConfig for .NET but have tons of trouble with it.
I installed the NuGet package Spring.CodeConfig into an existing .NET 4 project, but have had nothing but trouble with it.
The ScanAllAssemblies method throws a ReflectionTypeLoadException when I run this code:
var context = new CodeConfigApplicationContext();
context.ScanAllAssemblies();
context.Refresh();
This happens even if I have defined no configuration class, but it also happens if I create a configuration class.
The LoaderExceptions property contains a single exception with this message:
Could not load file or assembly 'System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))
I've tried adding an assembly redirect from version 1.0.3300.0 of System to version 4.0.0.0, which is the one that's referenced in my project, but this doesn't work.
How can I resolve this issue?
As requested, here are the references from the project in question:
- mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Ploeh.Samples.MenuModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- Spring.Aop, Version=1.3.1.40711, Culture=neutral, PublicKeyToken=65e474d141e25e07
- Spring.Core, Version=1.3.1.20711, Culture=neutral, PublicKeyToken=65e474d141e25e07
- Spring.Core, Version=1.3.1.40711, Culture=neutral, PublicKeyToken=65e474d141e25e07
- Spring.Core.Configuration, Version=1.0.0.4111, Culture=neutral, PublicKeyToken=65e474d141e25e07
- System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- xunit, Version=1.7.0.1540, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
Since the second reference is a project reference, I'm also listing its dependencies:
- mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I also have these binding redirects in my App.config - in case it matters:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Spring.Core" publicKeyToken="65e474d141e25e07" culture="neutral" />
<bindingRedirect oldVersion="1.3.1.20711" newVersion="1.3.1.40711" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="1.0.3300.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
However, both were attempts to fix problems with CodeConfig. Removing them doesn't help...