2011-11-30 50 views
1

我目前有以下操作簡單的WCF服務:WCF服務引用不會編譯

[OperationContract] 
int InsertApplication(Application application); 

的應用參數的定義如下:

[DataContract] 
public class Application 
{ 
    int test = 0; 

    [DataMember] 
    public int Test 
    { 
     get { return test; } 
     set { test = value; } 
    } 
} 

此服務被內消耗帶有命名空間SpringstoneColoAgent的Windows服務。我添加了一個沒有問題的服務參考OfficeInternalService。調用服務方法的代碼如下:

Application application = new Application();//= ConvertToApp(app); 
application.Test = 1; 
int oracleID = client.InsertApplication(application); 

但是,visual studio告訴我'application'是一個無效參數。在進一步的研究中,我試圖建立無論如何。我收到一些指向Reference.cs文件的錯誤。看着這個文件我確定所有的錯誤圍繞使用下面的代碼:

SpringstoneColoAgent.OfficeInternalService._ 

任何地方正在嘗試服務引用名下引用不正確。因此,例如,這段代碼是給了一個錯誤:

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOfficeInternalService/InsertApplication", ReplyAction="http://tempuri.org/IOfficeInternalService/InsertApplicationResponse")] 
int InsertApplication(SpringstoneColoAgent.OfficeInternalService.Application application); 

如果我不完全限定的命名空間,並刪除SpringstoneColoAgent.OfficeInternalService。使代碼如下所示:

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOfficeInternalService/InsertApplication", ReplyAction="http://tempuri.org/IOfficeInternalService/InsertApplicationResponse")] 
int InsertApplication(Application application); 

這將修復錯誤。我在任何地方重複了這一點,我可以找到錯誤,並且一切正常。缺點是,每次我對WCF服務進行更改並需要更新服務引用時,它都會丟失這些更改,我必須返回並更改它們。

我猜我在這裏失去了一些東西,並且很好奇,如果任何人有任何方向或遇到過類似的情況。

感謝您的任何建議!

回答