Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 无法从webservice访问用户定义的类_Asp.net_Wcf_Web Services_Serialization_Deserialization - Fatal编程技术网

Asp.net 无法从webservice访问用户定义的类

Asp.net 无法从webservice访问用户定义的类,asp.net,wcf,web-services,serialization,deserialization,Asp.net,Wcf,Web Services,Serialization,Deserialization,我是网络技术新手。我有一个名为Sample的Web服务。它引用了一个名为Custom.dll的dll。我的WebMethod正在从Custom.dll返回一个标记为序列化的类 //我的自定义类 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [SerializableAttribute()] [System.ComponentModel.DesignerCategoryAttribute("co

我是网络技术新手。我有一个名为
Sample
的Web服务。它引用了一个名为
Custom.dll
的dll。我的
WebMethod
正在从
Custom.dll
返回一个标记为序列化的类

//我的自定义类

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://somthing-something.mydomain.com/")]
public class CustomClass
{
    public string id;
    public string key;
}
//我的Web服务方法

[WebMethod]
public CustomClass MyWsMethod()
{
    return new CustomClass{id="id", key="Key"};
}
另外,我的Web服务是一个WCF服务,其中有一个
asmx
文件

我正在我的应用程序中使用此Web服务,服务将我的Web服务引用为
localhostWS
。我的应用程序还引用了
Custom.dll
。当我调用webservice方法时,我无法返回
Custom.CustomClass
对象。我正在返回
localhostWS.CustomClass
,而且我无法将其强制转换为
Custom.CustomClass

CustomClass-custom=localhostWS.MyWsMethod()

这里的
custom
对象的类型是
localhostWS.CustomClass
,但我希望
custom.CustomClass

有人能告诉我这里发生了什么事吗。请让我知道如果我需要提供任何进一步的信息。我已经尽力把我的问题弄清楚了

编辑


我还必须提到这一点,在不更改任何客户端代码的情况下实现这一点将非常好。由于种种原因,不可能改变这一点。不过,欢迎您提出任何建议。

WCF和ASMX不是一回事——我甚至不确定您是否可以在同一服务中同时提供这两种服务,尽管我可能会弄错这一点。在这两种情况下,
localhostWS.customClass
Custom.customClass
即使底层代码相同,也不会被.NET视为相同的东西,因为它们将被视为单独的程序集。我可以在WCF服务中添加asmx文件。是的,两者都被视为不同的对象,这就是我的问题所在。