WCF可以处理GUID吗?

时间:2011-11-01 19:20:12

标签: c# .net wcf web-services guid

我问,因为连接到我的本地开发人员数据库的单元测试使用Guids没有问题,但是当我通过我的WCF服务使用相同的方法时,它失败并出现以下异常:

System.Data.EntityCommandExecutionException

我已经阅读过WCF将Guids转换为字符串。我的具体情况是:

代理 - >使用Guid传递对象

服务< - 连接到db,插入/检索带Guid的东西

服务 - >使用Guid将对象传递回代理

从Web应用程序测试WCF服务时出现以下错误:

[FaultException`1: An error occurred while executing the command definition. See the inner exception for details.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9456095
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
   BusinessServices.NGIT.ServiceContracts.IIssueTrackerService.CreateIssue(CreateIssueRequest request) +0
   NGIT.Proxies.c__DisplayClass1.b__0(IIssueTrackerService s) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Proxies\IssueTrackerProxy.cs:25
   NGIT.Proxies.UseServiceFunction.UseService(ChannelFactory`1 channelFactory, Func`2 useService) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Helpers\UseServiceFunction.cs:26
   NGIT.Proxies.IssueTrackerProxy.CreateIssue(CreateIssueRequest request) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Proxies\IssueTrackerProxy.cs:25
   NGIT.Test.ClientProxy.Default.createIssueButtonClick(Object sender, EventArgs e) in D:\NextGenIssueTracker\branches\2011Updates\NGIT.Test.ClientProxy\Default.aspx.cs:36
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

以下是Trace Viewer的内部异常:

System.Data.EntityCommandExecutionException, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
An error occurred while executing the command definition. See the inner exception for details.

at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.ObjectContext.CreateFunctionObjectResult[TElement](EntityCommand entityCommand, EntitySet entitySet, EdmType edmType, MergeOption mergeOption)
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, MergeOption mergeOption, ObjectParameter[] parameters)
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ObjectParameter[] parameters)
at NGIT.Data.UserIssueEntities.CreateIssue(String issueTitle, String nextGenUserId, Nullable`1 guid) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Data\UserIssueObjectGenerator.cs:line 305
at Liberty.DataAccess.NGIT.SqlUserIssueRepository.AddIssue(User user, Issue issue) in D:\NextGenIssueTracker\branches\2011Updates\DataAccess.NextGenIssueTracker\Repositories\SqlUserIssueRepository.cs:line 51
at BusinessServices.NGIT.ServiceImplementations.IssueTrackerService.CreateIssue(CreateIssueRequest request) in D:\NextGenIssueTracker\branches\2011Updates\BusinessServices.NextGenIssueTracker\ServiceImplementations\IssueTrackerService.cs:line 59
at SyncInvokeCreateIssue(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)


2 个答案:

答案 0 :(得分:1)

我已经将WCF与基于GUID的实体一起使用,没有任何问题。我不认为这是你的问题,或者与WCF有关的事情。这听起来更像是数据库级别的问题:

EntityCommandExecutionException 的 表示底层存储提供程序无法执行指定命令时发生的错误。此异常通常包含特定于提供程序的异常。

答案 1 :(得分:1)

Yes.(.NET GUID - > Java String)

当然,实际问题不在于你发布的内容。