XmlSerializerAssemblyAttribute 类

定义

应用于 Web 服务客户端代理,可用来指定包含自定义序列化程序的程序集。Applied to a Web service client proxy, enables you to specify an assembly that contains custom-made serializers.

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)]
public sealed class XmlSerializerAssemblyAttribute : Attribute
type XmlSerializerAssemblyAttribute = class
    inherit Attribute
Public NotInheritable Class XmlSerializerAssemblyAttribute
Inherits Attribute
继承
XmlSerializerAssemblyAttribute
属性

注解

使用 XmlSerializerAssemblyAttribute 提高 Web 服务客户端应用程序的性能。Use the XmlSerializerAssemblyAttribute to increase the performance of a Web service client application.

使用此特性的典型方法如下:A typical method of using this attribute is as follows:

  1. 为 Web 服务创建客户端代理。Create a client proxy for a Web service.

  2. 打开 machine.config 文件。Open the machine.config file.

  3. 在 system.exception 元素下,在 <switches> 元素下添加一个值,以保留编译的文件:Under the system.diagnostics element, add a value under the <switches> element to keep the compiled files:

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

  5. 运行代理应用程序。Run the proxy application.

  6. 打开命令窗口,并导航到 XmlSerializer 用于缓存文件的 \Temp 目录。Open a command window and navigate to the \Temp directory used by the XmlSerializer to cache files.

    cd %temp%  
    
  7. 查找使用 " dir " 命令和 /od开关创建的最后一个文件。Find the last file created using the dir command with the /OD switch.

    dir *.vb /OD   
    
  8. 将文件编译到程序集。Compile the file into an assembly. 将程序集命名为。Name the assembly.

  9. 通过将 XmlSerializerAssemblyAttribute 应用到类来编辑原始代理代码。Edit the original proxy code by applying the XmlSerializerAssemblyAttribute to the class. 指定程序集名称,如下面C#的代码所示。Specify the assembly name, as shown in the following C# code.

    [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 类的新实例。Initializes a new instance of the XmlSerializerAssemblyAttribute class.

XmlSerializerAssemblyAttribute(String)

用指定的程序集名称初始化 XmlSerializerAssemblyAttribute 类的新实例。Initializes a new instance of the XmlSerializerAssemblyAttribute class with the specified assembly name.

XmlSerializerAssemblyAttribute(String, String)

用指定的程序集名称和程序集位置初始化 XmlSerializerAssemblyAttribute 类的新实例。Initializes a new instance of the XmlSerializerAssemblyAttribute class with the specified assembly name and location of the assembly.

属性

AssemblyName

获取或设置程序集的名称,该程序集包含一组特定类型的序列化程序。Gets or sets the name of the assembly that contains serializers for a specific set of types.

CodeBase

获取或设置包含序列化程序的程序集的位置。Gets or sets the location of the assembly that contains the serializers.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

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

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

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

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

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

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(继承自 Attribute)

适用于