2012-09-21 88 views
1

我被打壓了,我試圖更新現有服務引用WCF服務(共享類型),我不能。我嘗試了我在Google上找到的所有內容(social.msdn,stackoverflow,...),但我還沒有找到解決我的問題的方法。WCF更新服務參考錯誤

我已經有一個的ServiceContract和我一樣添加下面的代碼創建一個新操作:

[ServiceContract] 
public partial interface IServiceDTO : IGenericServiceDTO<EntityDTO>  
{ 
     // Some OperationContracts working like 
     [OperationContract] 
     EntityDTO[] Method(int field); 

     // NewMethod 
     [OperationContract] 
     OtherEntityDTO[] NewMethod(int field); 
} 

[DataContract] 
public class EntityDTO { 
    // Some properties working 
} 


[DataContract] 
public class OtherEntityDTO { 
    // Some properties working 
    [DataMember] 
    YetAnotherEntity NewProperty {get;set;} 
} 

當我嘗試更新它拋出我的follwing錯誤的服務參考:

Attempting to download metadata from 'http://localhost:65499/Services/Acciones/ProcesoServiceDTO.svc' using WS-Metadata Exchange or DISCO. Error: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Referenced type 'mpm.seg.ServiceModel.DTO.DataContracts.Acciones.ProcesoDTO, mpm.seg.ServiceModel.DTO.DataContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' with data contract name 'ProcesoDTO' in namespace 'http://schemas.datacontract.org/2004/07/mpm.seg.ServiceModel.DTO.DataContracts.Acciones' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IProcesoServiceDTO']

首先,我不明白句子「...由於與導入的DataContract不匹配而無法使用」。 svcutil如何試圖將引用類型與導入的DataContract匹配?我引用了在客戶端項目中引用類型的項目,原因是服務器和客戶端處於相同的解決方案中,但我試圖將它們分開並引用完全相同的dll。

此外,當我嘗試,例如,以下情況它的工作原理(寫「NewProperty」的「OtherEntityDTO到EntityDTO」的),我不明白的區別:

[ServiceContract] 
public partial interface IServiceDTO : IGenericServiceDTO<EntityDTO>  
{ 
     // Some OperationContracts working like 
     [OperationContract] 
     EntityDTO[] Method(int field); 

     // NewMethod 
     [OperationContract] 
     OtherEntityDTO[] NewMethod(int field); 
} 

[DataContract] 
public class EntityDTO { 
    // Some properties working 

    [DataMember] 
    YetAnotherEntity NewProperty {get;set;} 

} 


[DataContract] 
public class OtherEntityDTO { 
    // Some properties working 
} 

請,提前幫助我並多謝。

回答

0

對不起,但我發佈了問題後,我發現問題,並且這是一個報告的錯誤(http://blogs.msdn.com/b/distributedservices/archive/2010/02/04/wcf-client-issue-with-reuse-types-from-referenced-assemblies.aspx?wa=wsignin1.0)。另一位開發人員在父類上添加了這個屬性(IsReference = true),我不知道。現在我必須解決這個錯誤,但那是另一場戰鬥。

反正,我不明白爲什麼有時工作,有時不...

感謝。

0

我有一個類似的錯誤,但我的問題似乎有所不同。

我有一個只讀屬性,我不斷收到該錯誤。當我將其更改爲普通財產並添加了一套(沒有做任何事)時,合同工作正常。

+0

是的,你的問題是不同的,如果你想使用一個屬性作爲DataMember,它必須被獲取和設置爲了通過WCF序列化/反序列化。看看這個:[StackOverflow thread](http://stackoverflow.com/questions/1873741/wcf-exposing-readonly-datamember-properties-without-set) – Marc