Results 1 to 3 of 3

Thread: [Build] Cannot be called directly Error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2020
    Posts
    21

    [Build] Cannot be called directly Error

    My source code is as below. I get an error when trying to debug and I can't solve this error in any way.
    Please enlighten me with your knowledge, masters.

    Error BC32022 Public Shared Event ResponseHeadersAvailable As SessionStateHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

    Error BC32022 Public Shared Event BeforeResponse As SessionStateHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
    Name:  3PfLBg5.jpg
Views: 225
Size:  14.2 KB

    My Source Code:
    Code:
    Imports Fiddler
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Threading.Tasks
    
    Namespace FiddlerCore_ModifyResponse
        Class Program
            Private Shared Async Function Main(ByVal args As String()) As Task
                FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.bc.Debug", True)
                Dim certProvider As BCCertMaker.BCCertMaker = New BCCertMaker.BCCertMaker()
                CertMaker.oCertProvider = certProvider
    
               'THERE IS A PROBLEM
                FiddlerApplication.ResponseHeadersAvailable += AddressOf FiddlerApplication_ResponseHeadersAvailable
                Fiddler.FiddlerApplication.BeforeResponse += AddressOf FiddlerApplication_BeforeResponse
    
                If Not CertMaker.createRootCert() Then
                    Console.WriteLine("Unable to create cert for FiddlerCore.")
                    Return
                End If
    
                If Not CertMaker.trustRootCert() Then
                    Console.WriteLine("Unable to install FiddlerCore's cert.")
                    Return
                End If
    
                Dim startupSettings As FiddlerCoreStartupSettings = New FiddlerCoreStartupSettingsBuilder().ListenOnPort(8887).DecryptSSL().RegisterAsSystemProxy().Build()
                FiddlerApplication.Startup(startupSettings)
                Console.ReadKey()
                FiddlerApplication.Shutdown()
            End Function
    
            Private Shared Sub FiddlerApplication_BeforeResponse(ByVal oSession As Session)
                If oSession.fullUrl.Contains("raw.githubusercontent.com/3xynos/Valorous/main/zortlattim") AndAlso oSession.HTTPMethodIs("GET") Then
                    oSession.bBufferResponse = True
                    oSession.utilDecodeResponse()
                    oSession.utilDecodeResponse()
                    Dim oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes)
                    oBody = "Dnspy Adamdır [1]!"
                    oSession.utilSetResponseBody(oBody)
                End If
            End Sub
    
            Private Shared Sub FiddlerApplication_BeforeResponse2(ByVal oSession2 As Session)
                If oSession2.fullUrl.Contains("raw.githubusercontent.com/3xynos/Valorous/main/update") AndAlso oSession2.HTTPMethodIs("GET") Then
                    oSession2.bBufferResponse = True
                    oSession2.utilDecodeResponse()
                    oSession2.utilDecodeResponse()
                    Dim oBody2 = System.Text.Encoding.UTF8.GetString(oSession2.responseBodyBytes)
                    oBody2 = "Dnspy Adamdır [2]!"
                    oSession2.utilSetResponseBody(oBody2)
                End If
            End Sub
    
            Private Shared Sub FiddlerApplication_ResponseHeadersAvailable(ByVal oSession As Session)
                If oSession.fullUrl.Contains("testsite.com/test1.php") Then
                    oSession.bBufferResponse = True
                End If
            End Sub
    
            Private Shared Sub FiddlerApplication_ResponseHeadersAvailable2(ByVal oSession As Session)
                If oSession.fullUrl.Contains("testsite.com/test2.php") Then
                    oSession.bBufferResponse = True
                End If
            End Sub
        End Class
    End Namespace

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Sep 2020
    Posts
    21

    Re: [Build] Cannot be called directly Error

    i solved problem

    VB.NET has an AddHandler method that works similarly to the way the '+' overload operator works for adding event handlers in C#. There's no '+' used that way in VB. You specify the event you want to capture and the handler to fire when it occurs:

    You'd call it roughly like so:
    AddHandler FiddlerApplication.ResponseHeadersAvailable, AddressOf FiddlerApplication_ResponseHeadersAvailable
    AddHandler Fiddler.FiddlerApplication.BeforeResponse, AddressOf FiddlerApplication_BeforeResponse

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: [Build] Cannot be called directly Error

    If your issue is resolved then please use the Thread Tools menu to mark the thread Resolved. That way, we know that you don't need any more help without opening the thread and reading the whole thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width