0

Our executable was compiled against .NET 3.5. We don't own the source code and so can't recompile it. So, to get it to run with .NET 4.0, we added this to the config file, per this page:

<startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>

Now, we get a different error that seems related to the configuration file:

enter image description here

I suspected that there is something .NET 4.0 doesn't like about our fairly complex configuration file. To verify this, I did the following:

  • Created a blank .NET 3.5 WinForms exe
  • Added to the config the supportedRuntime as shown above
  • Verified that it ran up with the .NET 4.0 DLLs using process explorer.

I began to simplify the complex configuration file to narrow down the issue, and I got it down this far so far. Does anyone know what the problem could be?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <startup>
      <supportedRuntime version="v4.0" />
   </startup>
   <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 type="Spring.Context.Support.XmlApplicationContext, Spring.Core" name="Default">
      <resource uri="config://spring/objects" />
    </context>
    <objects xmlns="http://www.springframework.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd" default-lazy-init="true">      
      <object id="Foo1" type="Foo.Bar1, Foo.Bar">
        <description>lorem ipsum</description>
      </object>
      <object id="Foo2" singleton="false" type="Foo.Bar2, Foo.Bar">
        <description>lorem ipsum</description>
      </object>
      <object id="Foo3" singleton="false" type="Foo.Bar3, Foo.Bar">      
        <description>lorem ipsum</description>
      </object>
      <object id="Foo4" type="Foo.Bar4, Foo.Bar">            
        <description>lorem ipsum</description>
      </object>
      <object id="Foo5" type="Foo.Bar5, Foo.Bar">            
        <description>
            lorem ipsum
        </description>
        <constructor-arg>
          <list element-type="Foo.IBar5, Foo.Bar">
            <ref object="Foo4" />
          </list>
        </constructor-arg>
      </object>
    </objects>
  </spring>

</configuration>
Kara
  • 6,115
  • 16
  • 50
  • 57
ck.
  • 1,056
  • 1
  • 14
  • 25
  • possible duplicate of [Deciphering the .NET clr20r3 exception parameters P1..P10](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10) – Hans Passant Feb 13 '13 at 22:57
  • Are those XML namespace stuff really needed for Spring? I suspect that could be the issue. Remove them and try. – leppie Feb 14 '13 at 06:02

1 Answers1

1

Turns out the problem was that configSections has to be the first child of configuration.

I figured this out by putting the complex configuration into the blank WinForms config file, reading the configuration and looking at the details of the exception that was thrown.

ck.
  • 1,056
  • 1
  • 14
  • 25