title: Spring.Net Cannot instantiate a class
body: <p>error ::  Cannot instantiate a class that does not have a no-argument constructor [ClassLibrary2.Class1].</p>
  
  <p>I created a test project. </p>
  
  <p>i got the error source   in Spring src. 
  //////////////</p>
  
  <p>ConstructorInfo constructor = GetZeroArgConstructorInfo(objectType);  // in this , only zero arg  allow. But I use dependency inject constructor.  It doest work.
  ////</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ClassLibrary1
  {
     public interface IHi
      {
          string SayHi();
      }
  }
  
  
  
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ClassLibrary1
  {
      public class Class1:IHi
      {
          public string SayHi()
          {
              return "Hello Yeah";
          }
      }
  }
  
  
  
  
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using ClassLibrary1;
  namespace ClassLibrary2
  {
      public class Class1:IWannaSay
      {
  
  
          private readonly IHi Hi;
  ///Here doest work. prompts Cannot instantiate a class that does not have a no-argument constructor [ClassLibrary2.Class1].
  
          public Class1(IHi Hi)
          {
              this.Hi = Hi;
          }
  
  
          public string SayHi()
          {
  
             return  Hi.SayHi();
          }
  
      }
  }
  
  
  
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ClassLibrary2
  {
     public interface IWannaSay
      {
         string SayHi();
      }
  }
  
  
  
  
  
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using ClassLibrary2;
  namespace Mvc4.Controllers
  {
      public class HomeController : Controller
      {
          private readonly IWannaSay WannaSay;
  ///H ere works .Its so werid.
          public HomeController(IWannaSay WannaSay)
          {
              this.WannaSay = WannaSay;
  
          }
          public ActionResult Index()
          {
  
              var c = WannaSay.SayHi();
              ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
  
              return View();
          }
  
  }
  </code></pre>
  
  <p>My test.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;objects xmlns="http://www.springframework.net"&gt;
  
    &lt;object id="w" type="ClassLibrary2.Class1,ClassLibrary2"&gt;
    &lt;/object&gt;
    &lt;object id="Hi" type="ClassLibrary1.Class1,ClassLibrary1"&gt;
    &lt;/object&gt;
  
    &lt;object id="Hio" type="ClassLibrary2.Class1,ClassLibrary2"  singleton="false"&gt;
      &lt;!--构造器注入--&gt;
      &lt;!--&lt;constructor-arg  name="Hi"   ref="Hi"/&gt;--&gt;
      &lt;property name="Hi" ref="w"/&gt;
  
    &lt;/object&gt;
  
    &lt;object id="HomeCountroller" type="Mvc4.Controllers.HomeController,Mvc4"  singleton="false"&gt;
      &lt;!--构造器注入--&gt;
      &lt;constructor-arg  name="WannaSay"   ref="w"/&gt;
      &lt;!--&lt;property name="UserRespositoryImpl" ref="UserRespositoryImpl"/&gt;--&gt;
  
    &lt;/object&gt;
  
  
  &lt;/objects&gt;
  </code></pre>
  
  <p>web.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    --&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
      &lt;sectionGroup name="spring"&gt;
        &lt;section name="context" type="Spring.Context.Support.MvcContextHandler, Spring.Web.Mvc4" /&gt;
        &lt;section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /&gt;
        &lt;section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" /&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
    &lt;spring&gt;
      &lt;parsers&gt;
        &lt;parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" /&gt;
        &lt;parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" /&gt;
      &lt;/parsers&gt;
      &lt;context&gt;
        &lt;resource uri="assembly://Mvc4/Mvc4.Configs/test.xml" /&gt;
  
      &lt;/context&gt;
    &lt;/spring&gt;
    &lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Mvc4-20120919193749;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Mvc4-20120919193749.mdf" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="webpages:Version" value="2.0.0.0" /&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
      &lt;add key="PreserveLoginUrl" value="true" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/Login" timeout="2880" /&gt;
      &lt;/authentication&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Helpers" /&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Optimization" /&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;handlers&gt;
        &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /&gt;
        &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /&gt;
        &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
        &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /&gt;
        &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt;
        &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
      &lt;/handlers&gt;
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>