我正在为 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/