简体   繁体   English

实体框架:路径中的非法字符。 (连接字符串)(MVC3)

[英]Entity Framework: Illegal characters in path. (Connection String) (MVC3)

I just can't get this thing solved: 我只是无法解决这个问题:

I'm trying to use the Entity Framework in my MVC3 project. 我正在尝试在我的MVC3项目中使用实体框架。 But each time I call Entities context = new Entities(); 但每次我调用Entities context = new Entities(); I receive this error: Illegal characters in path. 我收到此错误:路径中的字符非法。 I do know this has something to do with my connectionstring, which is as follows: 我知道这与我的connectionstring有关,如下所示:

metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;Initial Catalog=databasename;Persist Security Info=True;User ID=username;Password=password;MultipleActiveResultSets=True"

I used Reflector to find out whether the resources where properly embedded in my assembly, and the answer is yes they are perfectly embedded in my assembly as Models.Model.csdl, .ssdl and .msl... 我使用Reflector来查明是否正确嵌入我的程序集中的资源,答案是肯定的,它们完全嵌入我的程序集中作为Models.Model.csdl,.ssdl和.msl ...

My Model is in the same assembly as were I'm trying to connect, and is NOT referenced, which means that the wildcard * should just work fine. 我的模型与我正在尝试连接的程序集相同,并且未被引用,这意味着通配符*应该可以正常工作。

The ConnectionString is exactly the same as generated by the wizard... ConnectionString与向导生成的完全相同......

[ArgumentException: Illegal characters in path.]
   System.IO.Path.CheckInvalidPathChars(String path) +142
   System.IO.Path.Combine(String path1, String path2) +46
   System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +41
   System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +237
   System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) +162
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +91
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +203
   System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +180
   System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +18
   System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +228
   System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +492
   System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +198
   System.Web.Mvc.<>c__DisplayClassc.<FindView>b__b(IViewEngine e) +47
   System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +177
   System.Web.Mvc.ViewResult.FindView(ControllerContext context) +144
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +151
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +784900
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +784976
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371

It doesn't even show the ActionResult where the problem is occuring... 它甚至没有显示出现问题的ActionResult ......

Finally, after removing the backslash in SERVERNAME\\INSTANCE it started working. 最后,在删除SERVERNAME \\ INSTANCE中的反斜杠后,它开始工作。 (added a alias to my SQL Server Instance without a backslash in it). (在我的SQL Server实例中添加了一个别名,但没有反斜杠)。 Probably can be solved as well by removing the backslash from illegal characters using the web.config...how it ever got on that list remains unknown 也许可以通过使用web.config从非法字符中删除反斜杠来解决...它在该列表上的表现仍然未知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 路径中包含非法字符。 C#加载控件 - Illegal characters in path. C# LoadControl System.ArgumentException: &#39;路径中有非法字符。&#39; - System.ArgumentException: 'Illegal characters in path.' 异常详细信息:System.ArgumentException:路径中的非法字符。 ASP.NET MVC - Exception Details: System.ArgumentException: Illegal characters in path. ASP.NET MVC 如何在文件路径中修复“路径中的非法字符”? - How to fix “Illegal characters in path.” in file path? Windows窗体设计器错误“路径中的字符非法”。 - Windows Form Designer Error “Illegal characters in path.” System.ArgumentException:路径中存在非法字符。 错误 - System.ArgumentException: Illegal characters in path. error Assembly.LoadFrom {“路径中的非法字符。”}错误 - Assembly.LoadFrom {“Illegal characters in path.”} error “路径中有非法字符。” 仅在从移动浏览器查看时 - “Illegal characters in path.” only when viewing from mobile browser 路径中的非法字符。 使用Skip并使用IEnumerable时出错 - Illegal characters in path. Error when using Skip and Take with IEnumerable XDocument.Load“路径中的非法字符。”错误,但是当我测试函数时,有XML - XDocument.Load “Illegal characters in path.” Error, but when I test the function there is the XML
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM