2010-10-31 2 views
1

Вот скриншот ошибки:ArgumentException был необработанным

alt text

Сама ошибка:

Заданных по имени соединение либо не найдено в конфигурации, не предназначена для использования с EntityClient, или недействителен.

Переход к app.config файл того же проекта я могу найти:

<?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> 

Строка подключения существует, но я получаю эту ошибку.

Я использую SQLite и .NET Framework 3.5.

Любые предложения?

+0

ли вы когда-нибудь решить это успешно? Вам все еще нужна помощь? – jcolebrand

ответ

0

Вы видели этот ответ? Помогает ли это?

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/f5904b4d-b2f8-421e-90de-339f93959533/

Цитирование:

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”. 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.

Смежные вопросы