Convert c# to vb.net 'RaiseEvent' statement to raise an event to use Gzip
Asked Answered
R

2

12

I have convert class from c# to vb.net .. My point that I want to compress asp.net page to reduce the page size ,, Problem is after i convert to vb.net ,i have this error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC32022: 'Public Event PostRequestHandlerExecute(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

Source Error:

Line 178:

Line 179: Private Sub Init(context As HttpApplication) Implements IHttpModule.Init

Line 180: context.PostRequestHandlerExecute += New EventHandler(context_BeginRequest)

Line 181: End Sub

Line 182:

im trying to implement Gzip for asp.net ... thanks in advance ....

Russ answered 16/11, 2012 at 3:38 Comment(0)
U
26

AddHandler is the VB.NET equivalent to C#’s += when used on events.

AddHandler context.PostRequestHandlerExecute, AddressOf context_BeginRequest
Unrobe answered 16/11, 2012 at 3:40 Comment(1)
Bingo. I don't know why but the Telerik converter messes this up and I don't use AddressOf enough to keep remembering this.Onesided
G
8

You need to use the AddHandler statement, not +=. that is c# syntax.

AddHandler context.PostRequstHandlerExecute, New EventHandler(AddressOf context_BeginRequest)
Gizzard answered 16/11, 2012 at 3:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.