ArgumentException的是未处理 [英] ArgumentException was unhandled

查看:187
本文介绍了ArgumentException的是未处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是错误的截图:

该错误本身是:

时,或者未在配置找到指定命名连接,并不意在与EntityClient提供者使用的,或不是有效的。

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

发往同一个项目中,我能找到的app.config文件:

Going to the app.config file of that same project I can find:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="DocumentsEntities" connectionString="metadata=res://*/Documents.csdl|res://*/Documents.ssdl|res://*/Documents.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;D:\Programming Projects\Desktop Applications\C#\DocumentScanner\DAL\Documents.sqlite&quot;'" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

连接字符串确实存在,但我发现这个错误。

The connection string does exist but I'm getting this error.

我使用的SQLite和.NET Framework 3.5。

I'm using SQLite and .NET Framework 3.5.

有什么建议?

推荐答案

你见过这样的回答?有何帮助?

Have you seen this answer? Does it help?

<一个href="http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/f5904b4d-b2f8-421e-90de-339f93959533/" rel="nofollow">http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/f5904b4d-b2f8-421e-90de-339f93959533/

报价:

我唯一的猜测是在app.config不   在二进制目录下的EXE   是。请执行以下操作:   1.目视确认与预期的内容在app.config   是在exe文件所在的目录   编译。在项目(存在   根目录是不够的。)   2.使用System.Configuration.ConfigurationManager   从您的应用程序内检查   在app.config你的EXE的内容   使用。我也期待在   连接字符串的内容,并   我可以说,它可能无法在正常工作   多项目环境(除非   你复制的EDM中的每个   项目)。其原因是。   解析为所在的目录   exe文件是由加载。如果你想   重复使用相同的EDM,你至少有   使退后几步路径   然后导航到该项目中,   电火花加工是,例如,   ...... \ Proj1 \ AdventureWorksModel。   此外,您还可以考虑使用   该| DataDirectory目录|宏观 - 当你   加载一个AppDomain可以设置   | DataDirectory目录|指向精确   目录所在的电火花加工,然后   使用该连接字符串中,   例如,

My only guess is the app.config is not in the binary directory where the exe is. Please do the following: 1. Visually verify that the app.config with the expected content is in the directory where the exe is compiled. (Existence in the project root directory is not enough.) 2. Use System.Configuration.ConfigurationManager from within your app to examine the content of the app.config your exe is using. I’m also looking at the content of the connection string, and I can say that it may not work in a multi project environment (unless you’ve duplicated the EDM in each project). The reason for that is "." resolves to the directory where the exe is loaded from. If you want to reuse the same EDM, you at least have to make a few steps back in the path and then navigate to the project where the EDM is, e.g. "......\Proj1\AdventureWorksModel". Additionally you may consider using the |DataDirectory| macro - when you load an AppDomain you can set |DataDirectory| to point to the exact directory where the EDM is, and then use that in the connection string, e.g.

| DataDirectory目录| \ AdventureWorksModel。   如果您在工作的一个ASP.NET   项目,你可以用〜是指   该项目的根。在后一   情况下,你不能引用模型   项目的分层结构外   虽然。

"|DataDirectory|\AdventureWorksModel". If you are working on an ASP.NET project, you can use "~" which refers to the project root. In that latter case, you can’t reference a model outside your project’s hierarchy though.

Zlatko Michailov Program Manager, 

     

数据可编程性运行微软   公司

Data Programmability Runtime Microsoft Corp.

这篇关于ArgumentException的是未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆