c# - WCF 部署到 Azure Entity Framework 方法返回异常

标签 c# mysql wcf entity-framework azure

我正在为 Windows Phone 应用程序开发 WCF。

数据库是MySQL,因此我使用ADO.net Entity Framework 来访问数据。 它在本地环境中运行良好。

但是,当我使用包实例将它们部署到 azure 时,使用 Entity Framework 的方法出现了异常。其他不需要数据库数据的方法可以很好地返回值,例如:getHello()

我正在使用 Visual Studio 的最新 mysql 连接器。

为了进行测试,我使用 WCFTestClient.exe。这是我调用该方法时返回的内容:

The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IService1.getUUser(Int32 userUid)
   at Service1Client.getUUser(Int32 userUid)

服务是http://unifiqsvc.cloudapp.net/Service.svc

我尝试修复的方法是:

getUUser() - 输入 1 到 3 的任意整数将返回帐户详细信息

updateLoc() - 在 uid、lat、longit 中输入任意整数(插入记录)

欢迎您访问该服务来帮助我。

最佳答案

已解决。

我确保 MySQL.Data.dll、MySQL.Web.dll、MySQL.Data.Entity.dll 和 System.Data.Entity.dll System.Data.Entity.Design System.Data.dll 都被复制本地(复制本地设置为 true)

将以下内容添加到您的 web.config 文件中:

  <system.data>
      <DbProviderFactories>
        <clear />
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
        description=".Net Framework Data Provider for MySQL"
        type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, 
        Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
      </DbProviderFactories>
    </system.data>

关于c# - WCF 部署到 Azure Entity Framework 方法返回异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17942823/

相关文章:

.net - 如何获取 header 值

c# - 使用自定义按钮从 CRM 中执行存储过程的最佳方法

c# - Assert.AreEquals 调用 object.Equals,无论 IEquatable 实现如何

PHP & PDO : Connect to MySQL using IPv6 address

c# - TryFind 是否有更紧凑的语法?

mysql - 将所有记录关系移动到另一条记录

MySQL 查询附加最新结果

WCF - 使用带有 net.tcp 绑定(bind)的 WS-Compression 未关闭套接字连接

c# - 将文本框添加到 gridview 页脚

c# - 如何仅使用 Azure Ad 用户名和密码连接和访问 Azure Datalake Gen1 存储 - c#