因此,我正在编写一个新的WCF服务,当它调用其中一个函数时,它应该返回一个Struct。该结构被保存在共享类中,因为它在程序的其他区域中使用。WCF服务无法从其他类返回结构?
的结构如下所示(请注意,这是一个VB.Net类中,有些项目是在C#):
<DataContract()>
Public Structure WrapperResults
<DataMember()>
Dim Success As Boolean
<DataMember()>
Dim ErrorMessage As String
End Structure
现在在WCF服务我已成立我有一个简单测试功能,看起来像这样:
public class TFXEmailProcessor : Wrapper
{
public MQShared.Functions.WrapperResults CallWrapper(string AppName, string Password, string ConfigXML)
{
MQShared.Functions.WrapperResults results = new MQShared.Functions.WrapperResults();
results.ErrorMessage = "TFX Test";
results.Success = true;
return results;
}
}
而在另一个类我已经加入到我的WCF服务,并试图把它的引用,如:
Dim myBinding As New BasicHttpBinding()
Dim endpointAddress As New EndpointAddress(WP.MyWrapper(x).WrapperURL)
Dim SR As New WrapperService.WrapperClient(myBinding, endpointAddress)
Dim WrapResults As MQShared.Functions.WrapperResults = SR.CallWrapper(AppName, Password, WP.MyWrapper(x).ConfigXML)
然而,SR.CallWrapper函数被Intellisense突出显示,并且我得到了错误Value of type 'FunctionsWrapperResults' cannot be converted to 'Functions.WrapperResults'
(注意FunctionsWrapperResults中的缺失时段)
有没有我在这里丢失的东西?
Dim WrapResults = SR.CallWrapper(AppName, Password, WP.MyWrapper(x).ConfigXML)
试图实现您的Datacontract以上StructLayout。 –
@Nagu_R尝试使用StructLayout.Auto但没有解决问题。 –
我相信,你会创建2套Wrapper结果类,并删除其中的一个/重命名。如果引用的程序集具有相同的程序集标识,则删除或替换其中一个文件引用,以便只有一个文件引用。 –