VB.NET中的Fiddler扩展DLL无法正常工作

时间:2014-10-05 02:48:11

标签: vb.net dll

现在,我正在用VS2010 for VB学习编程, 并尝试为Fiddler制作扩展DLL。

首先,我有一个“AustralianImages / ImageFlipper”的示例代码, 并在VB.NET中重写了它。

构建DLL文件已成功完成(虽然很难) 并将其复制到“Fiddler2 \ Scripts”文件夹,但Fiddler似乎没有 加载它。 使用文档文件夹或将.net Framework版本更改为2.0也不起作用。

有没有人有一些线索?感谢。

    Public Class MyFlip Implements IAutoTamper

    Private bEnabled As Boolean
    Dim oMenuItem As MenuItem = New MenuItem("M&y Flip")

    #Region "IAutoTamper Members"
    Public Sub OnBeforeReturningError(ByVal oSession As Session) Implements IAutoTamper.OnBeforeReturningError
    End Sub
    Public Sub AutoTamperRequestAfter(ByVal oSession As Session) Implements IAutoTamper.AutoTamperRequestAfter
    End Sub
    Public Sub AutoTamperRequestBefore(ByVal oSession As Session) Implements IAutoTamper.AutoTamperRequestBefore
    End Sub
    Public Sub AutoTamperResponseAfter(ByVal oSession As Session) Implements IAutoTamper.AutoTamperResponseAfter
    End Sub

    Public Sub AutoTamperResponseBefore(ByVal oSession As Session) Implements IAutoTamper.AutoTamperResponseBefore

        If (bEnabled = False) Then Exit Sub

        If oSession.ToString() <> String.Empty _
            And oSession.responseCode = 200 _
            And oSession.oResponse.ToString() <> String.Empty _
            And oSession.oResponse.headers.ToString() & oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/gif").ToString() & _
                oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/png").ToString() & _
                oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/jp").ToString() <> String.Empty Then
            Try
                oSession.utilDecodeResponse()
                Dim oStream = New MemoryStream(oSession.responseBodyBytes)
                Dim oBMP = New Bitmap(oStream)
                oBMP.RotateFlip(RotateFlipType.Rotate180FlipNone)

                Dim oNewStream = New MemoryStream()
                oBMP.Save(oNewStream, System.Drawing.Imaging.ImageFormat.Png)
                oSession.responseBodyBytes = oNewStream.GetBuffer()
                oSession.oResponse.headers("Content-Length") = oSession.responseBodyBytes.Length.ToString()
                oSession.oResponse.headers("Content-Type") = "image/png"
                oSession.oResponse.headers("Cache-Control") = "no-cache"
                oStream.Dispose()
                oNewStream.Dispose()
            Catch eX As Exception
                System.Diagnostics.Trace.WriteLine(eX.ToString(), "ImageFlipper Failed")
            End Try
        End If
    End Sub
    #End Region

    #Region "IFiddlerExtension_Members"
    Public Sub OnBeforeUnload() Implements IFiddlerExtension.OnBeforeUnload
        bEnabled = False
        oMenuItem.Dispose()
    End Sub

    Public Sub OnLoad() Implements IFiddlerExtension.OnLoad
        FiddlerApplication.Log.LogString("MyFlip OnLoad Start.")
        'oMenuItem = New MenuItem("M&y Flip")
        AddHandler oMenuItem.Click, AddressOf oMenuItem_Click

        FiddlerApplication.UI.mnuTools.MenuItems.Add(oMenuItem)
        MsgBox("vbOK!!")
        FiddlerApplication.Log.LogString("BB OnLoad End.")
    End Sub
    Sub oMenuItem_Click(ByVal sender As System.Object, _
                   ByVal e As System.EventArgs)
        oMenuItem.Checked = Not (oMenuItem.Checked)
        bEnabled = oMenuItem.Checked
    End Sub
    #End Region
    End Class

1 个答案:

答案 0 :(得分:0)

我不得不添加这句话......('·ω·`)

    <Assembly: Fiddler.RequiredVersion("2.4.6.0")> 

而且,,,,,实际上,我写的代码有误译 o会话条件判断。

有人请不要复制&amp;使用我的代码。

非常感谢。