I have an ASP.NET website project where I use VB.Net and C # class files. I have included separate subfolders in the App_Code directory for the classes of each language.
However, although I can successfully use the C # class in the VB class, I cannot do the opposite: use the VB class in the C # class.
So, to illustrate, I can have two such classes:
Public Class VBTestClass
Public Sub New()
End Sub
Public Function HelloWorld(ByVal Name As String) As String
Return Name
End Function
End Class
public class CSTestClass
{
public CSTestClass()
{
}
public string HelloWorld(string Name)
{
return Name;
}
}
I can use the CS class in my VB class with the Import statement. So this works well:
Imports CSTestClass
Public Class VBTestClass
Public Sub New()
End Sub
Public Function HelloWorld(ByVal Name As String) As String
Return Name
End Function
Private Sub test()
Dim CS As New CSTestClass
CS.HelloWorld("MyName")
End Sub
End Class
But using the VB class in my C # with the using statement does not work:
using VBTestClass;
public class CSTestClass
{
public CSTestClass()
{
}
public string HelloWorld(string Name)
{
return Name;
}
}
I get the error "Unable to find the type or namespace VBTestClass." What am I missing here?