Mar 2, 2010

c# and vb classes can be used in same asp.net 2 application

It is possible in asp.net 2 that c# an vb.net classes can be used in same project
All class files are contained in \app_Code folder which is compiled into single assembly.
It is possible that classes placed in same folder causes error. So make different folders in \app_data such as “vbclasses” and “c#classes”
    
\ App_Code              
                         \ vbclasses
                          \ c#classes
  
            
 now places  vb and c# classes in their respective folders as
\ App_Code              
                         \ vbclasses
                              someClass.vb
                          \ c#classes
                                 otherClass.cs
   
now we have to add some lines in web.config under the compilation key
<compilation>
   <codeSubDirectories>
      <add directoryName=”vbclasses”></add>
      <add directoryName=”c#classes”></add>
   </codeSubDirectories>
</compilation> 
now asp.net compile the code in single assembly and we can use the implementation of code placed in vb or c# class in our application without specifying their extensions

No comments:

Post a Comment