Signature.Sign 方法

定义

写 XML 数字签名块并计算签名数据的加密哈希。

public:
 abstract void Sign();
public abstract void Sign ();
abstract member Sign : unit -> unit
Public MustOverride Sub Sign ()

例外

表单代码尝试在签名启动之后写入基础 XML 文档。

没有使用“表单选项”对话框的“安全和信任”类别将表单模板配置为“完全信任”。

示例

下面的示例显示了当您为 Sign 事件添加事件处理程序时,添加到表单模板的代码框架。 首先,它使用 CreateSignature() 类的 SignatureCollection 方法创建新的 Signature 对象。 然后,它调用 类的 SignatureSign 方法,将新的 Signature 对象添加到窗体的 SignatureCollection 对象,而不显示“数字签名”对话框。

public void FormEvents_Sign(object sender, SignEventArgs e)
{
   // This event handler will run only in fully trusted form templates.

   Signature thisSignature = 
      e.SignedDataBlock.Signatures.CreateSignature();

   // To add other pieces of information to sign, modify the
   // signature template returned by
   // thisSignature.SignatureBlockXmlNode.
   // Write your code here.

   thisSignature.Sign();
   e.SignatureWizard = false;
}
Public Sub FormEvents_Sign(ByVal sender As Object, _
   ByVal e As SignEventArgs)

   ' This event handler will run only in fully trusted form templates.

   Dim thisSignature As Signature = _
      e.SignedDataBlock.Signatures.CreateSignature()

   ' To add other pieces of information to sign, modify the
   ' signature template returned by
   ' thisSignature.SignatureBlockXmlNode.
   ' Write your code here.

   thisSignature.Sign()
   e.SignatureWizard = False
End Sub

注解

只能从事件的事件处理程序Sign调用 Sign 方法。

只能由从表单模板打开的表单访问此成员,已使用“表单选项”对话框“安全和信任”类别将该模板配置为以完全信任状态运行。 此成员要求直接调用方的完全信任并且不能由部分信任的代码使用。 有关更多信息,请参阅 MSDN 上的“使用部分信任的代码中的库”。

可以通过 Microsoft InfoPath Filler 中打开的表单中运行的代码访问此类型或成员。

适用于