Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

C# class in App_code

Is it ok to add C# class to my existing web project - VB , under App_code and use it?  Will it runs?
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Source code in the app folder is compiled as one assenbly so you cannot mix languages.
You can configure your web application to treat different sub folders in the app folder as different assemblies.

Each folder can then contain source code in a different programming language. The configuration is specified by creating a codeSubDirectories element in the compilation element of the Web.config file and adding a reference to the subfolder. The following example illustrates how you would configure subfolders named VBCode and CSCode to compile into separate assemblies:

<compilation debug="false">    
    <codeSubDirectories>        
        <add directoryName="VBCode" />        
        <add directoryName="CSCode" />    
    </codeSubDirectories> </compilation>

Create the Two separate sub folders in App_code named VBCode (contains VB Class files *.vb) and CSCode (Contains CS Class files *.cs) then modify the web.config like this

<compilation debug="false">    
    <codeSubDirectories>        
        <add directoryName="VBCode" />        
        <add directoryName="CSCode" />    
    </codeSubDirectories> </compilation>
Avatar of VBdotnet2005

ASKER

One thing, can I call methods from C# classes in VB or the other way around?
How can I call C# class in VB page? Is it possbile?
ASKER CERTIFIED SOLUTION
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial