Debugging .NET Applications With Fiddler

If you want to debug a .NET application with Fiddler, you can force the application to proxy through Fiddler by adding this section to the application’s web.config or app.config:

<!-- The following section is to force use of Fiddler for all applications, including those running in service accounts -->  <system.net>
 <defaultProxy>
  <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
 </defaultProxy>
</system.net>

Fiddler listens on port 8888 by default, but if you are on a shared system, you might run into a situation where that port is already in use by other users who are also using Fiddler.

In this case, you can easily change the port that your Fiddler is listening on under TOOLS | OPTIONS | CONNECTIONS tab:

fiddler_options

If you change the port, be sure to also change it in the proxyaddress URL in the configuration above.

For reference, here’s the relevant Fidder documentation page for this topic:

https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureDotNETApp

 

Disk Inventory X

In a previous post, I mentioned that I use WinDirStat to view disk usage statistics on my PCs.

Well, there’s a similar tool named Disk Inventory X for OS X:

Image

This tool is invaluable when you are running low on disk space and you want to find out where all of your storage is being used.

Check it out!

Improving unit test coverage with NCrunch

My team has been doing a lot to improve unit test coverage lately, and one of the tools we rely on is NCrunch.

NCrunch provides real time feedback on your unit tests and coverage by running your tests in the background while you edit your code.

This provides a near instantaneous view of which lines of code are covered and what tests are failing and which lines are causing them to fail.

Check it out, it’s a great tool!

WinDirStat Utility

Is your hard drive getting full?

Ever wonder where all that space is being used?

Wonder no more! WinDirStat will show you exactly which folders contain the files that are taking up the most space on your drive.

WinDirStat Screen Shot

This is a great tool to use whenever you want to clean up your drive. It will display a sorted list of your folders and show you what percentage of space each one is using, then you can drill down into the folders to find the larger files and optionally delete them.

Great program! Check it out!

http://windirstat.info

 

Mixed Content in Internet Explorer

I spent a significant amount of time today tracking down a problem on one of our web applications.

One of our customers complained about seeing the infamous This Page Contains Both Secure and Nonsecure Items warning every time they viewed any of the site’s pages with Internet Explorer.

This page contains both secure and nonsecure items

This error occurs when you are viewing a web site over an SSL (HTTPS) connection, but there are one or more nonsecure items on the page.

In the end, our particular manifestation was due to having numerous iframe objects embedded in our pages with their src properties set to either javascript:void(0) or nothing at all.

The fix was to change all of these to use javascript:""; for their src property.

I found several resources online that were helpful in getting to the bottom of this problem:

The first is EricLaw’s excellent blog posting on the subject.

The other is this checklist for ruling out the possible causes.

Mercurial and Kiln

I’ve been working with the FogBugz bug tracker for quite a while now and I noticed that they offer a Mercurial based online version control system named Kiln.

I’ve been wanting to adopt one of these new-fangled distributed version control systems for some time now, so I decide to dive in and find out what all the fuss was about.

I read Joel Spolsky‘s excellent Mercurial tutorial, Hg Init and then set about installing Mercurial clients on all of my various workstations.

I ended up with TortoiseHG on my PC and MacHg on my Mac and so far I’m finding it to be a very flexible and easy to use system.

If you’re using Subversion or some other old-school version control system you should definitely take a look at Mercurial or GIT and see what you’re missing out on!

Dropbox

If you don’t have Dropbox installed, GO GET IT NOW!

www.dropbox.com

Dropbox is a program that lets you easily share and sync files amonst all of your computers (and phone).

It creates a folder that is automatically synchronized with all of the computers that you’ve installed Dropbox on. You can create a folder hierarchy and there is a public folder that you can put files that you want to share with others.

When you put a file into the public folder, you can right click and obtain a URL for that file, then you can send that URL to someone in an email or IM, and they can access the file just by clicking the link.

You can share folders with other Dropbox users, make it easy to share files amongst a group of people.

It also keeps a version history of the files allowing you to go back in time and access prior versions.

You can also access your drop box from any web browser anywhere you are, even if you don’t have your computer with you.

It’s really a great tool that has eliminated the need for me to carry a usb flash drive.

Go check it out now!

Dealing with the latest form of DLL hell

I’m working on a project which integrates a lot of legacy C++ code in several DLLs with a C# wrapper application.  Of course, the legacy code also references several third party libraries, just to make things interesting.

Everything was going well until I tried to run the application on a test VM and it displayed a very unhelpful error message:

This application has failed to start because the application configuration is incorrect.  Reinstalling the application may fix this problem.

The first thing I discovered, was that in order to run exectutables on a test machine that are linked to the DEBUG versions the VC runtime libraries, I’d need to copy the appropriate folders from the C:Program FilesMicrosoft Visual Studio 9.0VCredistDebug_NonRedist folder to the executable’s directory on the test machine.  Here’s some relevant information on MSDN regarding this:

http://msdn.microsoft.com/en-us/library/aa985618(VS.80).aspx

Unfortunately this was just the tip of the iceberg.

After copying the correct runtime library DLLs, I was still greeted with the same error when I tried to run my application.  The system event log contained a clue in the form of a SideBySide error:

A component version required by the application conflicts with another component version already active.

Hmm.  Some component wasn’t playing nice with some other component!

After a lot of googling, I ran across this Stack Overflow question which led to the eventual resolution:

http://stackoverflow.com/questions/59635/app-does-not-run-with-vs-2008-sp1-dlls-previous-version-works-with-rtm-versions

Apparently, some of the third party libraries were causing the linker to reference older VC runtime library versions, so our component’s manifest file was listing multiple versions.

This was apparently what was causing the problems on the test machine.

The fix was to add the following to the pre-processor directives for each of our projects which forces everything to reference the latest runtime libraries:

_BIND_TO_CURRENT_VCLIBS_VERSION

If you run into this, pay attention to this paragraph from the accepted answer which details a great way to debug this problem:

A great way to debug which libraries don’t have the preprocessor directives set: temporarily modify your platform headers so that compilation stops when it tries to embed the old manifest. Open C:Program FilesMicrosoft Visual Studio 9.0VCcrtincludecrtassem.h. Search for the ‘21022’ string. In that define, put something invalid (change ‘define’ to ‘blehbleh’ or so). This way, when you’re compiling a project where the _BIND_TO_CURRENT_CRT_VERSION preprocessor flag is not set, your compilation will stop and you’ll know that you need to add them or made sure that it’s applied everywhere.

This tip really helped me to identify and correct the projects which where causing the problem.

It’s amazing to me how far we’ve come from the days when this type of problem was routine.  With the advent of .NET, this sort of thing is rarely a problem until you try to use some old C++ libraries.  I hope you never have to deal with this sort of thing!