Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5991171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:20:56+00:00 2026-05-22T23:20:56+00:00

Scroll to the bottom, EDIT 19 onwards. See @Chris’s comments also for good examples

  • 0

Scroll to the bottom, EDIT 19 onwards. See @Chris’s comments also for good examples

VB:

Public Class Class1
    Private Delegate Sub AnEventHandler(Of T)(ByVal newValue As T)
    Private Event OnSomething As AnEventHandler(Of Nullable(Of Guid))
End Class

C#:

public class Class1
{
    private delegate void AnEventHandler<T>(T newValue);
    private event AnEventHandler<Nullable<Guid>> OnSomething;
}

With the above VB code in .Net3.5 and .Net 4, Visual Studio 2008 and 2010, regardless of project type, you get the following error:

Type ‘Global.System.Guid’ is not defined.

You cannot navigate to the error by double clicking, and no line/coloumn numbers are given.

Do not quote from here that:
“T” can only be a Class, an interface or a type parameter.

…because that is wrong, as proven below.

To confirm this statement, a couple of facts

Nullable is a structure. Yet, the following compiles:

Public Class Class1
    Private Delegate Sub AnEventHandler(Of T)(ByVal newValue As T)
    Private Event OnSomething As AnEventHandler(Of Nullable(Of Integer))
End Class

You can use Nullable Guids as shown here:

Private Sub StackOverflowTest()
    Dim s As Nullable(Of Guid)
    If s.HasValue Then
        'Do something
    End If
End Sub

That code compiles and works as you might imagine. Even the following code which uses generics and nullable guids works!!

Private Sub StackOverflowTest2(Of T)()
    ' do stuff
End Sub

Private Sub StackOverflowTest3()
    StackOverflowTest2(Of Nullable(Of Guid))()
End Sub

However, my particular example listed at the very top, does not work. Why? Clearly, T does work with structures…

EDIT 19ish! =D

  1. Create a VB.Net Console Application
  2. Add the following to “Module1.vb”

    Module Module1

    Sub Main()
        Dim testCase1 As Nullable(Of Integer)
        testCase1 = 2190
        StackOverflowTest1(Of Nullable(Of Integer))(testCase1)
        Dim testCase2 As Nullable(Of Guid)
        testCase2 = Guid.NewGuid
        StackOverflowTest1(Of Nullable(Of Guid))(testCase2)
        Dim testCase3 As Nullable(Of Guid)
        testCase3 = Nothing
        StackOverflowTest1(Of Nullable(Of Guid))(testCase3)
    End Sub
    
    Private Sub StackOverflowTest1(Of T)(ByVal param As T)
        Console.WriteLine(param.ToString)
    End Sub
    

    End Module

Results:

2190

5ef4ed7c-2720-4b37-b8ca-4ac044ec70d0

<<< Nothing here to it just gave carriage return

LAST EDIT (I hope):

It’s all gone quiet since Edit 19ish and @Chris reinforcing the issue with a good example (thank you Chris). I’ll make the question a little easier (and attempt to tidy up all of the above), can anyone prove this is not an MS bug or similar? It seems to be something under the hood is not correctly wired up for VB.Net with regards to Nullable Structures and Events? However, all other cases using the Nullable Structures does appear to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:20:57+00:00Added an answer on May 22, 2026 at 11:20 pm

    It would appear to be a bug in the code generated behind the scenes by the VB.Net compiler. The following compiles fine, and should be functionally equivalent:

    Public Class Class1
        Private Delegate Sub AnEventHandler(Of T)(ByVal newValue As T)
        Private OnSomethingEvent As AnEventHandler(Of Nullable(Of Guid))
        Private Custom Event OnSomething As AnEventHandler(Of Nullable(Of Guid))
            AddHandler(value As AnEventHandler(Of Nullable(Of Guid)))
                Me.OnSomethingEvent = DirectCast(System.Delegate.Combine(Me.OnSomethingEvent, value), AnEventHandler(Of Nullable(Of Guid)))
            End AddHandler
    
            RemoveHandler(value As AnEventHandler(Of Nullable(Of Guid)))
                Me.OnSomethingEvent = DirectCast(System.Delegate.Remove(Me.OnSomethingEvent, value), AnEventHandler(Of Nullable(Of Guid)))
            End RemoveHandler
    
            RaiseEvent(newValue As System.Guid?)
                Dim aeh = OnSomethingEvent
                If Not aeh Is Nothing Then
                    aeh(newValue)
                End If
            End RaiseEvent
        End Event
    End Class
    

    (Hence, also, why you don’t get line numbers for the errors – the errors are appearing in code that isn’t present in any line you’ve written)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to scroll and edit the cells at the bottom of the
There is a way to keep the scroll on bottom for a multi line
(Scroll down to bottom of post to find solution.) Got a asp.net page which
For an iPhone app I was using window.scrollBy to scroll to the bottom of
After calling notifydatasetchanged(); I want to scroll to the bottom of list so that
When you scroll down to the bottom of http://www.dzone.com/links/ it automatically loads more links.
I need to be able to scroll a RichTextBox to the bottom, even when
No matter how you scroll, the div should always be at the bottom of
The scroll lock button seems to be a reminder of the good old green
Go to the Starcraft II website at http://us.starcraft2.com/ and scroll down to the bottom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.