a developer's notes – a semi-technical web development BLOG

September 14, 2011

Ambiguous Reference Between Two NameSpaces

Filed under: ASP.NET,C# — Duy Nguyen @ 11:25 pm
Tags: , , , , , , ,

If you get an ambiguous reference error when using two different namespaces that contain the same object, you will need to use a type alias.

For example: Say you want to use the System.Drawing.Image type in your ASP.NET project. So you decide to add the System.Drawing namespace like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

You will get an ambiguous reference if you have that namespace along with the System.Web.UI.WebControls namespace.

Why? Because both namespaces contain an “Image” object.

Resolution: Use a type alias. In your using statement write using Image = System.Drawing.Image;.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Image = System.Drawing.Image;

Now when you hover over your Image type, you will see that you are now referencing the Image from System.Drawing.Image.

September 5, 2011

Comparing two dlls

Filed under: General Tips — Duy Nguyen @ 1:45 pm
Tags: , , ,

You can just use Beyond Compare to compare the binary differences with two dlls but what if you need to find out what the differences are? You can do the following:

To compare two dlls to see if they are different:

1. Use Reflector to extract the contents of the dll into two different directories

2. Use Beyond compare to compare the two folder’s content (and its content)

This way, you can know which file, that is different and what the different is, when comparing two dlls.

Create a free website or blog at WordPress.com.