XmlSerializerAssemblyAttribute 类

定义

应用于 Web 服务客户端代理后,可以指定包含自定义序列化程序的程序集。

public ref class XmlSerializerAssemblyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, AllowMultiple=false)]
public sealed class XmlSerializerAssemblyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, AllowMultiple=false)>]
type XmlSerializerAssemblyAttribute = class
    inherit Attribute
Public NotInheritable Class XmlSerializerAssemblyAttribute
Inherits Attribute
继承
XmlSerializerAssemblyAttribute
属性

注解

使用 提高 Web 服务客户端应用程序的性能。

使用此属性的典型方法如下所示:

  1. 为 Web 服务创建客户端代理。

  2. 打开 machine.config 文件。

  3. 在 system.diagnostics 元素下,在元素下 <switches> 添加一个值以保留已编译的文件:

    <system.diagnostics>  
       <switches>  
          <add name="XmlSerialization.Compilation" value="4"/>  
       </switches>  
    </system.diagnostics>  
    
  4. 编译代理。

  5. 运行代理应用程序。

  6. 打开命令窗口并导航到缓存文件所用的 XmlSerializer \Temp 目录。

    cd %temp%  
    
  7. 查找在 /OD 开关中使用 dir 命令创建的最后一个文件。

    dir *.vb /OD   
    
  8. 将文件编译为程序集。 为程序集命名。

  9. 通过向类应用 XmlSerializerAssemblyAttribute 原始代理代码来编辑原始代理代码。 指定程序集名称,如以下 C# 代码所示。

    [XmlSerializerAssemblyAttribute(AssemblyName="hello.serializer")]  
    public class Hello: System.Web.Services.Protocols.SoapHttpClientProtocol {  
       // Proxy code not shown.  
    }  
    
<XmlSerializerAssemblyAttribute(AssemblyName:="hello.serializer")> _  
Public Class Hello  
Implements System.Web.Services.Protocols.SoapHttpClientProtocol   
   ' Proxy code not shown.  
End Class  

构造函数

名称 说明
XmlSerializerAssemblyAttribute()

初始化 XmlSerializerAssemblyAttribute 类的新实例。

XmlSerializerAssemblyAttribute(String, String)

使用程序集的指定程序集名称和位置初始化类的新实例 XmlSerializerAssemblyAttribute

XmlSerializerAssemblyAttribute(String)

使用指定的程序集名称初始化类的新实例 XmlSerializerAssemblyAttribute

属性

名称 说明
AssemblyName

获取或设置包含特定类型集序列化程序的程序集的名称。

CodeBase

获取或设置包含序列化程序的程序集的位置。

TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否为派生类的默认值。

(继承自 Attribute)
Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,该信息可用于获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 Attribute)

适用于