at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)

最近在做一个WinForm的项目. 使用vs2013开发. 数据库使用的是oracle. 在本地写了一个webservice .测试正常.发布到服务器的时候.就是提示了错误. 打开服务器上的日志.看到如下信息:

System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   --- End of inner exception stack trace ---
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
   at Kerry.FW.Service.SecurityService.GetAuthenticateUserDetail(String userName, String password, String& errorMessage) in c:\K4\Kerry.K4\Kerry.FW.Service\SecurityService.svc.cs:line 57

开头有点纳闷. 因为之前做过另外一个系统 .也是使用EntityFramework , 数据库使用Oracle的.可以在服务器上正常运行.  所以认为oracle 驱动没注册的应该不大可能.结果看到了这篇文章

http://blog.csdn.net/greystar/article/details/9057159

里面提到了一种情况.就是在不同位(32bit/64bit)系统上开发时,visual studio 调用的机器配置文件 machine.config是不一样的. 而我恰恰也就是原先机器使用的是32位 来进行开发. 最近刚换到了 64位.

文中重点提到了

32位的machine.config 放在的是 (不同.NET Framework 版本对应不同的文件夹)

  C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

64位的machine.config 放在

  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config

出现驱动未注册的问题原因是 64位中的config 里面的system data 未配置一下内容

  

  <system.data>
    <DbProviderFactories>
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <add name="ODP.NET, Unmanaged Driver" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET, Unmanaged Driver" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
  </system.data>

我尝试在服务器上面加上这一段. 然后重新运行. 测试结果正常.

当然另外一种方式就是将当前的项目目标生成平台改位x86.

PS 关于Machine.config 的作用   http://www.cnblogs.com/dimg/archive/2005/11/12/274648.html

时间: 2024-08-27 08:30:17

at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)的相关文章

System.Security.SecurityException The type initializer for &#39;System.Data.Entity.Internal.AppConfig&#39; threw an exception

[15/08/19 00:03:10] [DataManager-7292-ERROR] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConf

System.Data.SqlClient.SqlException 超时时间已到

错误信息: 有关调用实时(JIT)调试而不是此对话框的详细信息, 请参见此消息的结尾. ************** 异常文本 ************** System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Timeout 时间已到.在操作完成之前超时时间已过或服务器未响应. (错误详细信息等于 很可能由 IncludeExceptionDetailInFaults=true 创建的 Except

关于System.Data.Entity.Core.MetadataException错误

发布ASP.NET MVC到IIS后出现错误: 1 System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: 2 SysModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Ma

No Entity Framework provider found for the ADO.NET provider with invariant name &#39;System.Data.SqlClient&#39;

异常描述: System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: PaycenterModels.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the pro

vs2015连接oracle 11g(.net自带方式 using System.Data.OracleClient;)

1,添加引用 System.Data.OracleClient 2,连接语句 string connectionString; string queryString; connectionString = "Data Source=127.0.0.1/orcl;User ID=scott;PassWord=TIGER"; queryString = "SELECT * FROM TEST"; OracleConnection myConnection = new O

SQL Server数据类型,System.Data.SqlDbType,.NET数据类型

SQL Server数据类型 System.Data.SqlDbType .NET数据类型 int SqlDbType.Int int varchar SqlDbType.VarChar string bit SqlDbType.Bit bool datetime SqlDbType.DateTime DateTime decimal SqlDbType.Decimal Decimal float SqlDbType.Float Double image SqlDbType.Image Byte

C++: read SQL server data using System::Data::SqlClient

stdafx.h: // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently #pragma once #using <mscorlib.dll> #using <System.dll> #using <System.Dat

未经处理的异常在 System.Data.dll 中发生。其他信息:在应使用条件的上下文(在 &#39;***&#39; 附近)中指定了非布尔类型的表达式。

机房收费系统中,有些人在联合查询这个模块用的是存储过程,我先尝试着在数据库中建立了一个视图,然后在UI层做个判断并生成查询条件strCondition. 在机房收费系统的"联合查询"模块中出现的问题:"System.Data.SqlClient.SqlException"类型的未经处理的异常在 System.Data.dll 中发生.其他信息: 在应使用条件的上下文(在 '@strCondition' 附近)中指定了非布尔类型的表达式. 出错的DAL层代码为: Pu

C#使用System.Data.SQLite操作SQLite

使用System.Data.SQLite 下载地址:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki 得到System.Data.SQLite.dll添加到工程引用: 建表,插入操作 static void Main(string[] args) { SQLiteConnection conn = null; string dbPath = "Data Source =" + Environmen