【发布时间】:2011-08-08 07:02:53
【问题描述】:
刚刚安装了 WCF CTP2 mar2011 并尝试通过浏览器访问 Web 服务。 (http://localhost:99/Services/MyDataService.svc/) 我得到了这个例外:
**The server encountered an error processing the request. The exception message is 'Value cannot be null. Parameter name: propertyResourceType'. See server logs for more details.** The exception stack trace is:
at System.Data.Services.Providers.ResourceProperty..ctor(String name, ResourcePropertyKind kind, ResourceType propertyResourceType)
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType resourceType, IProviderMetadata workspace, IDictionary`2 knownTypes, PrimitiveResourceTypeMap primitiveResourceTypeMap)
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary`2 knownTypes, IDictionary`2 childTypes, IDictionary`2 entitySets)
at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata()
at System.Data.Services.DataService`1.CreateProvider()
at System.Data.Services.DataService`1.HandleRequest()
at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
at SyncInvokeProcessRequestForMessage(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.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
有什么帮助吗?
更新。发现问题与此属性有关
[Required]
public byte TypeId { get; set; }
public ContactInfoType Type
{
get
{
return (ContactInfoType)TypeId;
}
set
{
TypeId = (byte)value;
}
}
有趣的是,在 WCF4 中一切正常。但它在 WCF CTP2march 中引发了异常。 ContactInfoType - 是一个枚举。
[IgnoreProperties("Type")] 无效。
更新2。在调查了一个问题后发现在属性的 setter 部分中抛出了异常。
public ContactInfoType Type
{
set
{
TypeId = (byte)value;
}
}
【问题讨论】:
-
我的水晶球丢了。你能发布一些代码吗?我唯一能告诉你的是,你不应该将
null作为propertyResourceType传递给ResourceProperty构造函数。 -
对此感到抱歉。添加了 Web 服务主体。我只是试图通过在浏览器中打开它来访问这个网络服务。
标签: c# wcf entity-framework-4.1 wcf-data-services