2013-07-17 36 views
0

我有一臺在安裝了MVC3的機器上開發的項目。我將該項目複製到安裝了3 MVC和MVC4的機器上。出於某種原因,我得到下面的錯誤。 MVC3和MVC4應該可以並排運行。我認爲這個錯誤與安裝MVC4有關,因爲會員提供者在3到4之間變化。我不確定如何隔離問題。在安裝了MVC3和MVC4的開發機器上運行MVC3項目時,如何解決ConfigurationErrorsException?如何在安裝了MVC3&4的服務器上運行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

在membership.cs文件的行號18處提供代碼。 Acme.Widget.Provider \ Membership.cs:line 18 –

+0

_repository = new StoredProcedureRepository();是membership.cs中第18行的代碼。連接字符串的構建方式存在一個錯誤。謝謝你幫我指出這一點。 – Tarzan

回答

0

原來,問題是由連接字符串的構建方式引起的。配置錯誤對診斷問題沒有幫助,但Ankush Jain的上述評論導致在正確的位置查找。連接字符串存儲在註冊表中。新機器是64位,舊機器是32位。更新代碼以檢查環境後,代碼正常工作。

相關問題