Broke the $1000 mark today!

Yeah, i finally made it. I wanted to break the $1000 mark and this morning when i checked my adsense stats, i had $1006 for the month of April 2008. This was one of my 2008 new year resolution as well, at least now i can say that i managed to fulfill one of those many resolutions that i always fail to honour every year 🙂

In just 4 months, i was able to reach that amount and that as well with only one website. Now my next goal is to reach the $1500 mark 🙂

Using Visual Studio 2005 with .NET Framework 3.5

If you want to try out the new features available in .NET 3.5, then the first thing you should do is download the 3.5 Framework from Microsoft using the link below:

Download .NET Framework 3.5

This will install everything you need to get started. Once you’ve run the setup, you can launch Visual Studio 2005 and create a new website project. To test that you are able to run C# 3.0 codes which is available in .NET Framework 3.5, go to the code behind of the Default.aspx page and insert the following codes:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		var _tempVar = 4;
		Response.Write(“Values of temp var: “ + _tempVar.ToString());
	}
}

If you try to compile the website, you will get an error because Visual Studio 2005 will not use .NET Framework 3.5 by default.

Error 63 The type or namespace name ‘var’ could not be found (are you missing a using directive or an assembly reference?) C:\Av\Web35\Default.aspx.cs 15 9 C:\Av\Web35\

To be able to take advantage of .NET 3.5 with Visual Studio 2005, you will need to add a web.config file (if you do not have one alreadyin your project) and replace the content with the following:

<?xml version=“1.0“?>
    <configuration>
        <configSections>
			<sectionGroup name=“system.web.extensions“ type=“System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“>
				<sectionGroup name=“scripting“ type=“System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“>
					<section name=“scriptResourceHandler“ type=“System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“ requirePermission=“false“ allowDefinition=“MachineToApplication“/>
					<sectionGroup name=“webServices“ type=“System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“>
						<section name=“jsonSerialization“ type=“System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“ requirePermission=“false“ allowDefinition=“Everywhere“/>
						<section name=“profileService“ type=“System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“ requirePermission=“false“ allowDefinition=“MachineToApplication“/>
						<section name=“authenticationService“ type=“System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“ requirePermission=“false“ allowDefinition=“MachineToApplication“/>
						<section name=“roleService“ type=“System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“ requirePermission=“false“ allowDefinition=“MachineToApplication“/>
					</sectionGroup>
				</sectionGroup>
			</sectionGroup>
    </configSections>

    <appSettings/>

    <connectionStrings/>

    <system.web>
        <compilation debug=“false“ strict=“false“ explicit=“true“>
          <assemblies>
            <add assembly=“System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089“/>
            <add assembly=“System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
            <add assembly=“System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089“/>
            <add assembly=“System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089“/>
          </assemblies>
        </compilation>

        <pages>
          <namespaces>
            <clear/>
            <add namespace=“System“/>
            <add namespace=“System.Collections“/>
			<add namespace=“System.Collections.Generic“/>
            <add namespace=“System.Collections.Specialized“/>
            <add namespace=“System.Configuration“/>
            <add namespace=“System.Text“/>
            <add namespace=“System.Text.RegularExpressions“/>
            <add namespace=“System.Linq“/>
            <add namespace=“System.Xml.Linq“/>
            <add namespace=“System.Web“/>
            <add namespace=“System.Web.Caching“/>
            <add namespace=“System.Web.SessionState“/>
            <add namespace=“System.Web.Security“/>
            <add namespace=“System.Web.Profile“/>
            <add namespace=“System.Web.UI“/>
            <add namespace=“System.Web.UI.WebControls“/>
            <add namespace=“System.Web.UI.WebControls.WebParts“/>
            <add namespace=“System.Web.UI.HtmlControls“/>
          </namespaces>

          <controls>
            <add tagPrefix=“asp“ namespace=“System.Web.UI“ assembly=“System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
            <add tagPrefix=“asp“ namespace=“System.Web.UI.WebControls“ assembly=“System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
          </controls>
        </pages>

        <authentication mode=“Windows“/>

        <httpHandlers>
          <remove verb=“*“ path=“*.asmx“/>
          <add verb=“*“ path=“*.asmx“ validate=“false“ type=“System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
          <add verb=“*“ path=“*_AppService.axd“ validate=“false“ type=“System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
          <add verb=“GET,HEAD“ path=“ScriptResource.axd“ validate=“false“ type=“System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
        </httpHandlers>

        <httpModules>
          <add name=“ScriptModule“ type=“System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
        </httpModules>
      </system.web>

      <system.codedom>
        <compilers>
          <compiler language=“c#;cs;csharp“ extension=“.cs“ type=“Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089“ warningLevel=“4“>
            <providerOption name=“CompilerVersion“ value=“v3.5“/>
            <providerOption name=“WarnAsError“ value=“false“/>
          </compiler>
          <compiler language=“vb;vbs;visualbasic;vbscript“ extension=“.vb“ type=“Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089“ warningLevel=“4“>
            <providerOption name=“CompilerVersion“ value=“v3.5“/>
            <providerOption name=“OptionInfer“ value=“true“/>
            <providerOption name=“WarnAsError“ value=“false“/>
          </compiler>
        </compilers>

      </system.codedom>

      <system.webServer>
        <validation validateIntegratedModeConfiguration=“false“/>
        <modules>
          <remove name=“ScriptModule“/>
          <add name=“ScriptModule“ preCondition=“managedHandler“ type=“System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
        </modules>

        <handlers>
          <remove name=“WebServiceHandlerFactory-Integrated“/>
          <remove name=“ScriptHandlerFactory“/>
          <remove name=“ScriptHandlerFactoryAppServices“/>
          <remove name=“ScriptResource“/>
          <add name=“ScriptHandlerFactory“ verb=“*“ path=“*.asmx“ preCondition=“integratedMode“ type=“System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
          <add name=“ScriptHandlerFactoryAppServices“ verb=“*“ path=“*_AppService.axd“ preCondition=“integratedMode“ type=“System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
         <add name=“ScriptResource“ verb=“GET,HEAD“ path=“ScriptResource.axd“ preCondition=“integratedMode“ type=“System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35“/>
       </handlers>

     </system.webServer>

     <runtime>
       <assemblyBinding xmlns=“urn:schemas-microsoft-com:asm.v1“>
         <dependentAssembly>
           <assemblyIdentity name=“System.Web.Extensions“ publicKeyToken=“31bf3856ad364e35“/>
           <bindingRedirect oldVersion=“1.0.0.0-1.1.0.0“ newVersion=“3.5.0.0“/>
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name=“System.Web.Extensions.Design“ publicKeyToken=“31bf3856ad364e35“/>
           <bindingRedirect oldVersion=“1.0.0.0-1.1.0.0“ newVersion=“3.5.0.0“/>
         </dependentAssembly>
       </assemblyBinding>
     </runtime>
   </configuration>

This is the default web.config that is created in Visual Studio 2008 and it will compile your website without any errors. However the only problem you will encounter with using Visual Studio 2005 with .NET Framework 3.5 is that you are not able to use intellisense for the features which are new in .net 3.5 since the Visual Studio 2005 IDE does not support that!

C# 3.0 new features

If you want to see the power of the new features in C# 3.0, i suggest you take a look at the video from Tim Rayburn which shows you how you would use the new C# 3 features. Below is a list of what is covered:

  • Automatic Properties
  • Implicitly typed variable
  • Object Initialisers
  • Collection Initialisers
  • LINQ and Anonymous types
  • Lambda Expressions
  • Extension Methods

And here’s the link to the flash C# 3.0 video.

C# ASP.NET magazine

I wanted to get a magazine that is going to cover the latest news on C#, ASP.NET and Visual Studio so that i stay updated with the advances in technology. However i didn’t want a digital version as i spend too much time as it is on the internet and was looking for something which i could read on the train while commuting to work. The paper print C# magazines which i found are below:
Visual Studio Magazine – Yearly Cost $78.97 (Rest of the world including UK), $34.97 United States [12 issues]

asp.netPRO – Yearly Cost $79.99 (Rest of the world including UK), $34.99 United States [12 issues]

MSDN Magazine – Yearly Cost $72 (England) [12 issues]

CoDe Magazine – Yearly Cost $29.99 (United States) [6 issues]

.NET Developer’s Journal

I think the Visual Studio magazine is the best one out so far as it gives good examples on C# codes and new techniques in ASP.NET 2.0, 3.0, 3.5 and covers new features of Visual Studio 2008.