I am attempting to define new namespaces and classes within a new VB.NET project; however, Visual Studio is not allowing me to instantiate any of my new namespaces/classes/methods.
I have.....
- set up a new project in Visual Studio 2019 Community;
- created a new namespace (SignInSignOut) with a single class (TestClass) and one method (ShowMessageBox);
- attempted to Import the new namespace into an existing code-behind page (Default.aspx.vb); and
- attempted to instantiate the new class and method from the Page_Load() method of the code-behind page.
The attempt to Import the new namespace into the existing code-behind page fails.
The new Namespace, Class and Method.....
Imports Microsoft.VisualBasic
Namespace SignInSignOut
Public Class TestClass
Public Shared Sub ShowMessageBox(ByVal sString As String)
MsgBox(sString)
End Sub
End Class
End Namespace
The attempt to import the Namespace.Class and instantiate the Method on the Default.aspx.vb code-behind page.....
Imports SignInSignOut.TestClass
Public Class _Default
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
ShowMessageBox("This is just a test!")
End Sub
End Class
Edit
I resolved the issue by re-installing Visual Studio 2019 Community. I had reinstalled an old copy of VS 2010 Pro and the example worked as expected, which led me to believe I might have a problem with VS 2019 Community.