在Test Client(WCF)中测试时出现WCF ConfigurationErrorsException [英] WCF ConfigurationErrorsException when testing in Test Client (WCF)

查看:70
本文介绍了在Test Client(WCF)中测试时出现WCF ConfigurationErrorsException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我测试我的服务时(第一次),我得到以下例外:

 System.Configuration.ConfigurationErrorsException未被用户代码处理
HResult = -2146232062
消息=无法找到或加载已注册的.Net Framework数据提供程序。
Source = System.Data
BareMessage =无法找到或加载已注册的.Net Framework数据提供程序。
Line = 0
StackTrace:
at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.EntityClient.EntityConnection.GetFactory( String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString( String newConnectionString)
at System.Data.Objects.ObjectContext..ctor( String connectionString, String defaultContainerName)
在ExamGeneratorDataModel.ExamEntities..ctor() d:\ my documents \visual studio 2010 \ Projects\examgenerator\ExamGeneratorDataModel\ExamGeneratorModel.Designer.cs:line 46
at examgenerator.UserService.GetUser( String userName) d:\ my documents \visual studio 2010 \Projects\examgenerator\examgenerator\UserService.cs:line 31
在examgenerator.UserService.Login( String userName, String password)中的class =code-keyword> d:\ my documents \visual studio 2010 \Projects\examgenerator\examgenerator\UserService.cs:line 19
在SyncInvokeLogin(对象对象 [], Object [])
Object 实例,对象 []输入,对象 []&输出)
在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
InnerException:





在我的app文件中,我从我的数据模式中添加了一个连接字符串属性:



 <?  xml     version   =  1.0   编码  =  utf-8 < span class =code-summarycomment>   >  
< 配置 >
< b> < connectionStrings >
< add 名称 = ExamEntities connectionString = metadata = res:/ /*/ExamGeneratorModel.csdl|res://*/ExamGeneratorModel.ssdl|res://*/ExamGeneratorModel.msl;provider=MySql.Data.MySqlClient;provider connection string =& quot; server = localhost; User Id = root;密码= 0000; Persist Security Info = True; database = exam& quot; providerName = System.Data.EntityClient / >
< / connectionStrings >
< system.web >
< 编译 debug = true / >
< / system.web >
..
..
..





错误抛出我转移到此代码:



public ExamEntities(): base name = ExamEntities ExamEntities
{
this .ContextOptions.LazyLoadingEnabled = true ;
OnContextCreated();
}





我尝试用Google搜索,甚至重新阅读John Sharp的Windows Communication Foundation 4 Step by Step我还没有发现这里可能有什么问题:-(。我甚至关闭了我的反病毒(什么?我非常绝望): - )

解决方案

发现解决方案。我没有添加:



使用MySql.Data.MySqlClient; 



< br $> b $ b不要怪我。我们都做到了。所有! ; - )


Hi,

When i test my service (for the first time), i get the following exception:

System.Configuration.ConfigurationErrorsException was unhandled by user code
  HResult=-2146232062
  Message=Failed to find or load the registered .Net Framework Data Provider.
  Source=System.Data
  BareMessage=Failed to find or load the registered .Net Framework Data Provider.
  Line=0
  StackTrace:
       at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
       at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
       at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
       at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
       at ExamGeneratorDataModel.ExamEntities..ctor() in d:\my documents\visual studio 2010\Projects\examgenerator\ExamGeneratorDataModel\ExamGeneratorModel.Designer.cs:line 46
       at examgenerator.UserService.GetUser(String userName) in d:\my documents\visual studio 2010\Projects\examgenerator\examgenerator\UserService.cs:line 31
       at examgenerator.UserService.Login(String userName, String password) in d:\my documents\visual studio 2010\Projects\examgenerator\examgenerator\UserService.cs:line 19
       at SyncInvokeLogin(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
  InnerException: 



In my app file, i have added a connection strings attribute as such from my data mode:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="ExamEntities" connectionString="metadata=res://*/ExamGeneratorModel.csdl|res://*/ExamGeneratorModel.ssdl|res://*/ExamGeneratorModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;password=0000;Persist Security Info=True;database=exam&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" />
  </system.web>
..
..
..



The error is thrown an i am transfered to this code:

public ExamEntities() : base("name=ExamEntities", "ExamEntities")
       {
           this.ContextOptions.LazyLoadingEnabled = true;
           OnContextCreated();
       }



I have tried googling and even re-reading John Sharp's Windows Communication Foundation 4 Step by Step and i have not found what could be wrong with here :-( . I even turned off my anti-virus (what?.. I was very desperate) :-)

解决方案

Found the solution. I had not added:

using MySql.Data.MySqlClient;



Do not blame me. We have all done that. ALL! ;-)


这篇关于在Test Client(WCF)中测试时出现WCF ConfigurationErrorsException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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