在具有MVC3&amp ;;的服务器上运行MVC3项目时,如何解决ConfigurationErrorsException? 4安装?

时间:2013-07-17 18:22:14

标签: asp.net-mvc

我有一个在安装了MVC3的机器上开发的项目。我将项目复制到安装了3 MVC和MVC4的机器上。出于某种原因,我收到以下错误。 MVC3和MVC4应该能够并行运行。我认为错误与安装MVC4有关,因为成员资格提供者在3到4之间变化。我不知道如何隔离问题。在安装了MVC3和MVC4的开发机器上运行MVC3项目时,如何解决ConfigurationErrorsException?

System.Configuration.ConfigurationErrorsException was unhandled by user code
  Message=Exception has been thrown by the target of an invocation. (C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.Web\web.config line 42)
  Source=System.Web
  BareMessage=Exception has been thrown by the target of an invocation.
  Filename=C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.Web\web.config
  Line=42
  StackTrace:
       at System.Web.Security.Membership.Initialize()
       at System.Web.Security.Membership.get_Provider()
  InnerException: System.Reflection.TargetInvocationException
       Message=Exception has been thrown by the target of an invocation.
       Source=mscorlib
       StackTrace:
            at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
            at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
            at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
            at System.Activator.CreateInstance(Type type, Boolean nonPublic)
            at System.Web.HttpRuntime.CreatePublicInstance(Type type)
            at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
       InnerException: System.NullReferenceException
            Message=Object reference not set to an instance of an object.
            Source=Acme.Widget.DAL
            StackTrace:
                 at Acme.Widget.DAL.Utilities.GetRegistryValue(String registryKeyPath, String valueName) in C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.DAL\Utilities.cs:line 67
                 at Acme.Widget.DAL.Utilities.GetConnectionString() in C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.DAL\Utilities.cs:line 15
                 at Acme.Widget.DAL.StoredProcedureRepository..ctor() in C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.DAL\StoredProcedureRepository.cs:line 21
                 at Acme.Widget.Provider.Membership..ctor() in C:\Projects\Acme\BOM&MRP\AcmeWidget\Acme.Widget.Provider\Membership.cs:line 18
            InnerException: 

提前致谢。

1 个答案:

答案 0 :(得分:0)

原来问题是由连接字符串的构建方式引起的。配置错误对诊断问题没有帮助,但Ankush Jain上面的评论导致找到正确的位置。连接字符串存储在注册表中。新机器是64位,旧机器是32.更新代码以检查环境后,代码工作正常。