【问题标题】:MVC3 EE CTP - Format of the initialization string does not conform to specification starting at index 0MVC3 EE CTP - 初始化字符串的格式不符合从索引 0 开始的规范
【发布时间】:2011-08-24 14:56:42
【问题描述】:

我有一个小型 MVC 3 Entity code 第一个应用程序,我在本地数据库中创建了表并备份了表并恢复了 winhost 虚拟主机数据库上的数据。

在我的 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

【问题讨论】:

    标签: entity-framework linq-to-sql asp.net-mvc-3 linq-to-entities


    【解决方案1】:

    您为什么仍在使用 CTP?该版本已经发布了一段时间。升级,然后看看你的问题是否仍然存在。这可能是一个固定的问题。

    【讨论】:

    • 我正在使用最新版本的实体框架,看起来 Linq 解析有问题。
    【解决方案2】:

    堆栈跟踪指出您的连接字符串存在问题。

    修复你的连接字符串,问题就会消失。

    【讨论】:

    • 相同的连接字符串在我的本地机器上工作,它在 winhost 网络服务器中失败
    • @sfgroups: 也许它从其他地方获取连接字符串?连接字符串可能为空?
    猜你喜欢
    • 2012-01-04
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多