类序列化问题

如何解决类序列化问题

| 我在以下课程中出现错误,但不确定它在哪里。该类将在我的服务中正确返回,但不会序列化并返回任何结果。任何帮助将不胜感激。
Imports System
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses
Imports System.Data.EntityClient
Imports System.ComponentModel
Imports System.Xml.Serialization
Imports System.Runtime.Serialization

\' <summary>  
\'<para>This class is used to load Email objects.</para>  
\' <para>
\' CreateDate: 6-14-2011
\' ModifyDate: 6-14-2011
\' ModifyDesc: Initial Creation
\' </para>
\' </summary>  
\' 
#Region \"Email\"
\'\'\' <summary>
\'\'\' Email class.
\'\'\' </summary>
<DataContractAttribute(IsReference:=True)>
<KnownTypeAttribute(GetType(CompanyLocEmail))>
<KnownTypeAttribute(GetType(CompanyEmail))>
<KnownTypeAttribute(GetType(UserEmail))>
Partial Public MustInherit Class Email

    #Region \"Declarations\"
    <DataMemberAttribute()>
    Private _IsPreferred As Nullable(Of Global.System.Boolean)
    <DataMemberAttribute()>
    Private _EmailTypeL As Global.System.String
    <DataMemberAttribute()>
    Private _EmailTypeS As Global.System.String
    <DataMemberAttribute()>
    Private _EmailAddress As Global.System.String
    <DataMemberAttribute()>
    Private _XID As Global.System.Int32
    <DataMemberAttribute()>
    Private _EID As Global.System.Int32
    #End Region

    #Region \"Primitive Properties\"
    #Region \"IsPreferred\"
    \'\'\' <summary>
    \'\'\' IsPrefferred.
    \'\'\' </summary>
    Public Property IsPreferred() As Nullable(Of Global.System.Boolean)
        Get
            Return _IsPreferred
        End Get
        Set(value As Nullable(Of Global.System.Boolean))
            OnIsPreferredChanging(value)
            _IsPreferred = value
            OnIsPreferredChanged()
        End Set
    End Property

    Partial Private Sub OnIsPreferredChanging(value As Nullable(Of Global.System.Boolean))
    End Sub

    Partial Private Sub OnIsPreferredChanged()
    End Sub
    #End Region

    #Region \"EmailTypeL\"
    \'\'\' <summary>
    \'\'\' EmailTypeL.
    \'\'\' </summary>
    Public Property EmailTypeL() As Global.System.String
        Get
            Return _EmailTypeL
        End Get
        Set(value As Global.System.String)
            OnEmailTypeLChanging(value)
            _EmailTypeL = value
            OnEmailTypeLChanged()
        End Set
    End Property

    Partial Private Sub OnEmailTypeLChanging(value As Global.System.String)
    End Sub

    Partial Private Sub OnEmailTypeLChanged()
    End Sub
    #End Region

    #Region \"EmailTypsS\"
    \'\'\' <summary>
    \'\'\' EmailTypeS.
    \'\'\' </summary>
    Public Property EmailTypeS() As Global.System.String
        Get
            Return _EmailTypeS
        End Get
        Set(value As Global.System.String)
            OnEmailTypeSChanging(value)
            _EmailTypeS = value
            OnEmailTypeSChanged()
        End Set
    End Property

    Partial Private Sub OnEmailTypeSChanging(value As Global.System.String)
    End Sub

    Partial Private Sub OnEmailTypeSChanged()
    End Sub
    #End Region

    #Region \"EmailAddress\"
    \'\'\' <summary>
    \'\'\' EmailAddress.
    \'\'\' </summary>
    Public Property EmailAddress() As Global.System.String
        Get
            Return _EmailAddress
        End Get
        Set(value As Global.System.String)
            OnEmailAddressChanging(value)
            _EmailAddress = value
            OnEmailAddressChanged()
        End Set
    End Property

    Partial Private Sub OnEmailAddressChanging(value As Global.System.String)
    End Sub

    Partial Private Sub OnEmailAddressChanged()
    End Sub
    #End Region

    #Region \"EID\"
    \'\'\' <summary>
    \'\'\' EID.
    \'\'\' </summary>
    Public Property EID() As Global.System.Int32
        Get
            Return _EID
        End Get
        Set(value As Global.System.Int32)
            If (_EID <> value) Then
                OnEIDChanging(value)
                _EID = value
                OnEIDChanged()
            End If
        End Set
    End Property

    Partial Private Sub OnEIDChanging(value As Global.System.Int32)
    End Sub

    Partial Private Sub OnEIDChanged()
    End Sub
    #End Region

    #Region \"XID\"
    \'\'\' <summary>
    \'\'\' XID.
    \'\'\' </summary>
    Public Property XID() As Global.System.Int32
        Get
            Return _XID
        End Get
        Set(value As Global.System.Int32)
            If _XID <> value Then
                OnXIDChanging(value)
                _XID = value
                OnXIDChanged()
            End If
        End Set
    End Property

    Partial Private Sub OnXIDChanging(value As Global.System.Int32)
    End Sub

    Partial Private Sub OnXIDChanged()
    End Sub
    #End Region

    #End Region
End Class
#End Region

#Region \"CompanyEmail\"
\'\'\' <summary>
\'\'\' CompanyEmail class.
\'\'\' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class CompanyEmail
    Inherits Email

    #Region \"Declarations\"
    <DataMemberAttribute()>
    Private _Company As Company
    #End Region

    #Region \"Factory Method\"
    \'\'\' <summary>
    \'\'\' Create a new CompanyEmail object.
    \'\'\' </summary>
    \'\'\' <param name=\"emailTypeL\">Initial value of the EmailTypeL property.</param>
    \'\'\' <param name=\"emailTypeS\">Initial value of the EmailTypeS property.</param>
    \'\'\' <param name=\"emailAddress\">Initial value of the EmailAddress property.</param>
    \'\'\' <param name=\"eID\">Initial value of the EID property.</param>
    \'\'\' <param name=\"xID\">Initial value of the XID property.</param>
    Public Shared Function CreateCompanyEmail(emailTypeL As Global.System.String,emailTypeS As Global.System.String,emailAddress As Global.System.String,eID As Global.System.Int32,xID As Global.System.Int32) As CompanyEmail
        Dim companyEmail As CompanyEmail = New CompanyEmail
        companyEmail.EmailTypeL = emailTypeL
        companyEmail.EmailTypeS = emailTypeS
        companyEmail.EmailAddress = emailAddress
        companyEmail.EID = eID
        companyEmail.XID = xID
        Return companyEmail
    End Function
    #End Region

    #Region \"ParentProperties\"
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    Public Overridable Property Company() As Company
        Get
            Return _Company
        End Get
        Set(value As Company)
            _Company = value
        End Set
    End Property
    #End Region
End Class
#End Region

#Region \"CompanyLocEmail\"
\'\'\' <summary>
\'\'\' CompanyLocEmail class.
\'\'\' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class CompanyLocEmail
    Inherits Email

    #Region \"Declarations\"
    Private _CompanyLoc As CompanyLoc
    #End Region

    #Region \"Factory Method\"
    \'\'\' <summary>
    \'\'\' Create a new CompanyLocEmail object.
    \'\'\' </summary>
    \'\'\' <param name=\"emailTypeL\">Initial value of the EmailTypeL property.</param>
    \'\'\' <param name=\"emailTypeS\">Initial value of the EmailTypeS property.</param>
    \'\'\' <param name=\"emailAddress\">Initial value of the EmailAddress property.</param>
    \'\'\' <param name=\"eID\">Initial value of the EID property.</param>
    \'\'\' <param name=\"xID\">Initial value of the XID property.</param>
    Public Shared Function CreateCompanyLocEmail(emailTypeL As Global.System.String,xID As Global.System.Int32) As CompanyLocEmail
        Dim companyLocEmail As CompanyLocEmail = New CompanyLocEmail
        companyLocEmail.EmailTypeL = emailTypeL
        companyLocEmail.EmailTypeS = emailTypeS
        companyLocEmail.EmailAddress = emailAddress
        companyLocEmail.EID = eID
        companyLocEmail.XID = xID
        Return companyLocEmail
    End Function
    #End Region

    #Region \"ParentProperties\"
    <DataMemberAttribute()>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    Public Overridable Property CompanyLoc() As CompanyLoc
        Get
            Return _CompanyLoc
        End Get
        Set(value As CompanyLoc)
            _CompanyLoc = value
        End Set
    End Property
    #End Region
End Class
#End Region

#Region \"UserEmail\"
\'\'\' <summary>
\'\'\' UserEmail class.
\'\'\' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class UserEmail
    Inherits Email

    #Region \"Declarations\"
    Private _UserRole As UserRole
    #End Region

    #Region \"Factory Method\"
    \'\'\' <summary>
    \'\'\' Create a new UserEmail object.
    \'\'\' </summary>
    \'\'\' <param name=\"emailTypeL\">Initial value of the EmailTypeL property.</param>
    \'\'\' <param name=\"emailTypeS\">Initial value of the EmailTypeS property.</param>
    \'\'\' <param name=\"emailAddress\">Initial value of the EmailAddress property.</param>
    \'\'\' <param name=\"eID\">Initial value of the EID property.</param>
    \'\'\' <param name=\"xID\">Initial value of the XID property.</param>
    Public Shared Function CreateUserEmail(emailTypeL As Global.System.String,xID As Global.System.Int32) As UserEmail
        Dim userEmail As UserEmail = New UserEmail
        userEmail.EmailTypeL = emailTypeL
        userEmail.EmailTypeS = emailTypeS
        userEmail.EmailAddress = emailAddress
        userEmail.EID = eID
        userEmail.XID = xID
        Return userEmail
    End Function
    #End Region

    #Region \"ParentProperties\"
    <DataMemberAttribute()>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    Public Overridable Property UserRole() As UserRole
        Get
            Return _UserRole
        End Get
        Set(value As UserRole)
            _UserRole = value
        End Set
    End Property
    #End Region
End Class
#End Region
接口定义
<OperationContract()> _
Function GetEmail(iID As Integer) As UserEmail
实际通话
    Public Function GetEmail(iID As Integer) As UserEmail Implements InsightDataAPIInterface.GetEmail
    Dim ret = (From c In db.Emails Where c.EID = iID Select c).Take(1)
    Dim y As UserEmail
    For Each x In ret
        y = CType(x,UserEmail)
    Next x
    \'Breakpoint  here shows correct data in y,so y returns the class
    Return y
End Function
这将不是GetEmail的最终版本,但是我正在它的当前状态下使用它来尝试弄清楚为什么我没有让类正确地序列化。如果有人能以正确的方向推动我,我将背负很大的债务。 :)     

解决方法

        尝试在
<DataContract>
声明中添加Namespace属性。在Visual Basic中,我看到了很多情况,客户端/服务器项目的Root Namespace属性是不同的(它们默认为项目名称,应该是不同的)-根名称空间最终被用来定义类的CLR命名空间。如果未显式设置数据协定的名称空间,则WCF将使用CLR名称空间,并且如果客户端/服务器类位于不同的名称空间中,则会看到类似的错误。
<DataContractAttribute(IsReference:=True,Namespace:=\"http://my.namespace.com\")>
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-