tags:

views:

144

answers:

3

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?

A: 

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.

Shoban
Why the down vote?
Shoban
+1 - Seems like a sensible answer to me.
CJM
A: 

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 :-)

Jakob Christensen
Is this correct? We can have .cs and .vb in the same project. We have to make some changes in the web.config file.
Shoban
No, with app_code folder you can mix.
Canavar
I am trying to make reference but it asks for DLL/EXE. Do I need to compile class library proj?
Tom
No!!! You just have to copy the .cs file to App_Code folder and the class will be automatically compiled. BTW what version are you using?
Shoban
Use the "Project" tab in the "Add reference" dialog box.
Jakob Christensen
+1  A: 
  1. Ensure you declared your class public.

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

Canavar