I am trying to use myclass.cs from aspx.vb but receive error "myclass not declared" when I give command:

Imports myclass

any ideas how to make a reference?

Was it helpful?


You cannot mix C# and VB.NET code files in the same project. You need to add a new C# class library project containing myclass.cs and then add a reference to this project from your VB project.

EDIT: Apparently I was mistaken. You CAN actually mix VB and C# in a web project if you put the .cs files in the App_Code folder. You learn something new every day :-)


  1. Ensure you declared your class public.

  2. Put your C# class into the App_Code folder.

Copy the .cs file to App_Code folder and you should be able to import it. You can read more about App_Code folder here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow