0

我有小MVC 3實體代碼的第一個應用程序,我在我的本地數據庫中創建了表並且還原了winhost上的數據虛擬主機數據庫。MVC3 EE CTP - 初始化字符串的格式不符合從索引0開始的規範

在我的web.config我有更改連接字符串winhost連接開始。它在我的桌面上擦了擦。

我將本地應用程序轉移到了Windows,當訪問應用程序時我收到了這個錯誤。

來自此方法的錯誤。

public ActionResult ListRecords() 
     { 
      var query = from e in db.Envelopes 
         orderby e.ReportDate descending 
         select e; 
      IEnumerable<Envelopes> top10 = query.Take(25); 

      return View(top10.ToList<Envelopes>()); 
     } 

錯誤消息:

Format of the initialization string does not conform to specification starting at index 0. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.] 
    System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +5025863 
    System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +132 
    System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98 
    System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +64 
    System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24 
    System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150 
    System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59 
    System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4 
    System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name) +399 
    System.Data.Entity.Internal.LazyInternalConnection.Initialize() +49 
    System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() +10 
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +252 
    System.Data.Entity.Internal.InternalContext.Initialize() +16 
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +16 
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +61 
    System.Data.Entity.Internal.Linq.InternalSet`1.get_Provider() +15 
    System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +13 
    System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +66 
    Envelopesonly.Controllers.HomeController.ListRecords() in HomeController.cs:84 
    lambda_method(Closure , ControllerBase , Object[]) +40 
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +188 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +56 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267 
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +20 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329 
    System.Web.Mvc.Controller.ExecuteCore() +115 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31 
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 

任何修復此錯誤的幫助?

感謝 SR

回答

0

你爲什麼還在使用CTP?該版本已經出現了相當長的一段時間。升級,然後查看您的問題是否仍然存在。這可能是一個固定的問題。

+0

我正在使用最新版本的實體框架看起來像Linq解析問題。 – sfgroups 2011-05-15 22:54:09

0

堆棧跟蹤指出連接字符串存在問題。

修復您的連接字符串,問題應該消失。

+0

相同的連接字符串在我的本地機器上工作,它在winhost web服務器上失敗 – sfgroups 2011-05-16 01:21:07

+0

@sfgroups:也許它從別的地方獲取連接字符串?連接字符串可能是空的? – fretje 2011-05-16 16:13:10

相關問題