Browsing Category dotNet

.NET Adoption in Startups

July 6th, 2010 // 7:53 am @ Amar

A very interesting article over at Aaronontheweb about .NET Adoption in Startups. Some really excellent comments also giving very different viewpoints. Quite an interesting read.

Category : dotNet

HTML 5 with Visual Studio 2010

July 1st, 2010 // 12:55 pm @ Amar

If you have tried to create / edit an HTML 5 document in Visual Studio, you must have got a lot of validation errors. The current validator in Visual Studio 2010 supports HTML 4.01 or XHTML 1.1 Transitional as the highest standards.

To enable Intellisense to work with HTML 5, perform the following steps:

  1. Download the HTML5 support package for Visual Studio 2008 from the Visual Web Developer team here.
  2. Copy the html_5.xsd in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\schemas\html
  3. Edit the correct registry file and replace 9.0 with 10.0
    The file will look like this ( 64 bit VS 2010 Ultimate for me ):
  4. Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas\Schema 23]
    "File"="html\\html_5.xsd"
    "Friendly Name"="HTML 5"
    "URI"="http://schemas.microsoft.com/intellisense/html-5"

  5. Run the registry file to merge it with your registry.
  6. Open Visual Studio 2010
  7. Go to Tools->Options->Text Editor->HTML->Validation
  8. Select target as HTML 5

This would allow you to get Intellisense for your HTML 5 based projects.

Category : General & dotNet

Typemock ASP.NET Bundle

May 21st, 2009 // 2:30 am @ Amar

Hi everyone. After using Typemock on one of my projects, I can definitely say that it is a fantastic product for your unit testing. Have just heard about a promotion which Typemock is running currently to promote their new produt and giving away licences. See the details below:

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle – and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you’ll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Category : dotNet

Getting all XML Key Value pairs in XSL

January 30th, 2009 // 2:13 am @ Amar

May times when I try to design a XSL against an unknown data stream, I would like to know what all values are available. Here is a nifty XSL which I have been using for a while. ( I am sure there are many versions out there ).

<xsl:for-each select="@*">
    <br/> Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." />
</xsl:for-each>

It gives a list of all elements with their values. Quite handy to check if you have got the element name wrong etc.

Category : dotNet

Configure ASP.NET Websites to output XHTML to W3C Validator

November 12th, 2008 // 12:15 pm @ Amar

In my previous blog entry, I showed how to configure ASP.NET to output XHTML to the browsers. However, when the W3C Validator checks the page, ASP.NET does not know the W3C user agent and hence sends out non compliant code. The trick is in the w3cvalidator.browser file available on idunno.org. Just drop the file in your App_Browsers folder and ASP.NET will send out XHTML compliant code to the Validator.

Category : dotNet

Making ASP.NET XHTML Compliant

November 12th, 2008 // 8:48 am @ Amar

ASP.NET by default does not emit XHTML compliant code. Consider this scenario. You have carefully created an XHTML compliant design. Created your pages using ASP.NET and when you try to validate your page, it fails with the error :

Line x, Column y: there is no attribute “name”.

<form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">

This leaves you a bit stunned, as ASP.NET adds the name tag to the form on compile and you don’t have any control over it. However, don’t worry. There is a solution.

Just add to following under system.web in your web.config file. 
<

 

xhtmlConformance mode=Strict/>

ASP.NET should generate compliant code now, and you should see the following in your rendered output.

<form method="post" action="default.aspx" id="aspnetForm">

As you see, it does not render the name tag anymore. Problem solved. Time to display the W3C Validated icons on your page with pride :)

Category : dotNet

Analyse your Source Code

June 6th, 2008 // 10:51 am @ Amar

I recently gave Microsoft Source Analysis a try. It was released sometime ago, and act’s as an add-in in Visual Studio to check the source code with some coding rules. This is different from FxCop which checks assemblies. This checks your source code before it is compiled right in Visual Studio editor.I did like the tool. Quite handy, but will need a little bit getting used to.

Some companies may need to change some rules to match their coding standards. For people who don’t have a particularly though out coding standard in place, and are using something from the ASP / VB / C days, it may be worth changing over the standard based on the Source Analysis rules, as it has been in use for quite a while at some parts of Microsoft, and from an overall look, it does look quite a decent one.

There are a few irritations, but you can turn rules on and off. The most irritating part is that it throws up tons of errors in the Visual Studio generated code. Also, another irritation is that the default rules need a header on every page. However, it is not a bad thing. Either you can toggle the rule off, or write a header. Doh… Most of you like me will go, how do I write a header which Source Analysis will understand? Well, worry not, help is at hand.You can use the following header for your code files:

//———————————————————————–
// <copyright file=”Program.cs” company=”Your Company Name”>
// Copyright (c) Your Company Name. All rights reserved.
// </copyright>
// <author>Your Name</author>
//———————————————————————–

What about the Visual Studio auto-generated files? You don’t need to worry about Source formatting and coding practices in those files. So how do we exclude them from being checked? Well, there is a simple enough way.Just add the following header in all files you don’t want checked by Source Analysis.

// <auto-generated />


For more details about headers, you can check out the rules documentation on the Source Analysis Blog.


Lastly, now, you are sort of morally forced to document every method. I know it’s a bit of an effort for all lazy developers like me. So GhostDoc come here to rescue us from our plight. For those of you, who don’t know about Ghost Doc, shame on you. Just kidding ;) It is a cool VS Add-In by Roland Weigelt, which auto generates method descriptions by guessing it from the description. It is not perfect, but definitely a big leap from the Visual Studio way. Download it and I can assure you that you will seriously get addicted to it. Combine together Ghost Doc and Source Analysis, make coding much clearer, better documented and developer friendly.

Category : dotNet

Debugging .NET Source Code

January 17th, 2008 // 1:01 pm @ Amar

Shawn Burke has a nice article which explains how to enable Visual Studio to download the symbol files and enable debugging for the .NET Source Code in your project. This is definitely a big help, as we no longer have to treat internal .NET assemblies as a black box, but gives us a the power to find out why an error happened and what kind of data the runtime expects?


Have a look at this excellent article and start configuring your development environment to support it.

Category : dotNet

dotNet 3.5 Namespace Poster

November 20th, 2007 // 10:11 am @ Amar

Just a quick update. Found this cool poster of .net 1.0 – 3.5 namespaces. Definitely a must to hang around any developer’s cubicle ;)  Download it straight from Microsoft.

Category : dotNet

.NET Code Performance

November 22nd, 2006 // 8:11 pm @ Amar

I recently had been busy performance tuning .NET code, and I was very surprised at some of the findings as I timed and profiled various code modules. I had done a lot of performance tuning with C++ before I migrated to .NET. Had not done any serious performance tuning till now with .NET. While I was profiling a SharePoint WebPart, these findings would be equally applicable to any .NET code.


I was surprised to see that accessing a property off an object had a surprising big hit. e.g.


MyObject is an object which has a property say, ID.


I have a loop of code which uses the MyObject and tried to compare the ID with something…


for (int i =0; i < 100; i ++)
{


if ( MyObject.ID == something)
do something…
}


I observed that there were a few milliseconds being spend whenever I tried to access MyObject.ID.


Alternatively the following code ran much faster.


int id = MyObject.ID


for (int i =0; i < 100; i ++)
{


if ( id == something)
do something…
}


I guess the overhead of accessing the object and getting the property value does have a hit and can take up time if say you have a recursive function or an iterative function. Will be careful of such cases in the future.


I guess I will spend a bit more time exploring the internals of .NET to profile and find out such cases which can make a difference in our code.


P.S. I know I have not been posting to this blog for a bit. I am trying to move my blog to a better host and with better control over it. Yahoo Hosting is not adequate for it, as I cannot do a lot of things I plan to do with my Wordpress installation. Hence will mostly be moving this site to a new server which does not have restrictions. So busy evaluating offers and packaged from hundreds of hosting companies to find one which is just right for a geek developer like me, who would like to have enough control when needed from time to time.

Category : SharePoint & dotNet

Latest Posts

Testimonials

"Amar clearly has a thorough knowledge of Sharepoint, this knowledge, coupled with his professionalism and dedication made him a tremendous asset to the project. He was the key contributor to the later stages of the project delivery effort (the really difficult bit, long hours and hard work that puts huge demands on people), and I can state categorically that without his focussed dedication and hard work we would not have been able to meet the timescales imposed upon the project."

Tim Ellis , Sharepoint Project Manager , Royal Bank of Scotland

Subscribe Now