Skip to main content

Posts

Showing posts from June, 2007

R.I.P Visual Basic

Are Visual Basic days numbered? Over last few weeks I have been hearing that Microsoft is going to stop supporting Visual Basic at some point in future. C# is the language of future. Here, according to some, are few evidences of it. 1. There are new versions of C# but no major development in VB.net 2. Microsoft uses C# for example in most of the articles/journals. Do a quick search on "VB.Net a dead language" and you will find some interesting article. I would like to hear your views on this. Personally I think C# is a much better language than VB.Net even though most of my experience has been in VB. The syntax of C# is much more clear and easy to understand. I must say I am converted and given a choice I will prefer coding in C#. DebugGuru

Sharing code across multiple pages/ web applications

There are times when you will want to share code across several pages in your site. There are 3 ways of doing it. 1. The code directory (APP_CODE). Just copy your .vb or .cs file in app_code and it will be dynamically compiled. 2. Local assembly (BIN directory). Compile your code and copy the dll file in BIN. 3. Global Assembly Cache. You can register a strongly typed assembly using regasm.exe. Alternatively you can register a assembly using web.config I will explain each of these in details in my next few blogs. DebugGuru

Shared code in multiple languages.

By default, the App_Code directory can only contain files of the same language. However, you may partition the App_Code directory into subdirectories (each containing files of the same language) in order to contain multiple languages under the App_Code directory. To do this, you need to register each subdirectory in the Web.config file for the application. <system.web> <compilation> <codesubdirectories> <add directoryname="CSharpCode"> <add directoryname="VBCode"> <add directoryname="CPPCode"> </codesubdirectories> </compilation> </system.web> </configuration>

Database deployment

In past it has been a pain for developers to deploy a database driven application. You had to go through a list of SQL scripts to create tables and other database objects. In ASP.Net 2.0, you can copy the . mdf file in \APP_DATA folder. Then XCOPY the entire application folder on the web server. Following one line of code in web. config will attach the database for you. connectionString =" Data Source =.\SQLExpress;AttachDbFile=|DataDirectory|\ASPNETDB.MDF;Database = dbASPNETDB . MDF ; User Instance=True; Trusted_Connection = Yes;" The above connection string assumes you have an instance of SQL Server called SQLExpress running on you local machine. ASPNETDB . MDF is available in APP_DATA folder. ASPNET is trusted user.