Getting active on DZone

A while ago, on April 6th, one of my posts, Exeptions and Errors in Java, became a DZone Big Link. As a result, the link was tweeted automatically and is available at DZone’s Twitter. I was really happy to be noticed in Web icon smile Getting active on DZone

But today I got pleased even more! I was noticed again; I received invitation to join DZone’s Most Valuable Blogger program. What it is, according to DZone:

DZone’s Most Valuable Blogger program brings together a group of highly talented bloggers, authors, and technologists actively writing about topics of interest to the developer community. These people are recognized in the industry for their contributions and deep technical knowledge on subjects ranging from software design and architecture to programming on a range of platforms including Java, .NET, Ruby and others.

You can see the list of MVBs at Meet the DZone MVBs. At the moment there are about 200 people listed and, as far as I have noticed, only a couple of them lives in Poland.

Update, 2010-07-12
I am now officially an MVB!

Update, 2010-07-23
Just got an MVB t-shirt too icon smile Getting active on DZone

big mvbbutton Getting active on DZone

Visual Studio Team System: Files are not checked out automatically when edited

It happened to me after connection to TFS was dropped. and I was moved to offline work mode. Default VSTS settings say whenever you start editing a file it will be automatically checked out and it will appear on Pending Changes window. However, after those connection problems I no longer experienced that behavior.

Solution

First of all it’s worth checking VSTS Source Control related settings according to this article. In my case everything was fine there.

The problem on my side was somewhere else. After I had gone offline I had to go online again (what a surprise?!). I was expecting that to happen after reconnecting to TFS, but that is not entirely true. What I had to do as well was use ‘Go online’ button at the top of solution explorer. Once pressed it listed all the files I had modified while in offline mode and VSTS started working as before.

An attempt was made to load a program with an incorrect format. Exception from HRESULT: 0x8007000B (BadImageFormatException)

Note: I assume you can rebuild the program you are having problems with because changes in its configuration settings are required.

If you are struggling with this problem you are probably running 64bit OS and executing 64bit exe that loads 32bit dll, or the other way – 32bit OS on which 32bit exe tries loading 64bit dll. For the sake of this post, let’s assume this is the former matter.

Solution

You need to assure that 32bit dll is loaded by the program with the same bittness, even if it’s running on 64bit platform.

In order to achieve that you need to change the configuration settings of the project whose outcome is that exe so that platform target is always x86, disregarding configuration platform. Let’s assume that program is written in C#.

Open project’s properties, go to Build tab and make change as below:

cs project settings 350x140 An attempt was made to load a program with an incorrect format. Exception from HRESULT: 0x8007000B (BadImageFormatException)

MFC: CButton and how ON_BN_DOUBLECLICKED message map works

Microsoft Foundation Classes (MFC) library provides CButton which, according to MSDN, can be used for creating a check box, a radio button, and a pushbutton.

There are two events CButton supports: (i) ON_BN_CLICKED (single click), (ii) ON_BN_DOUBLECLICKED (double click). Let’s assume you provide a meaningful implementation for a single click and do nothing in the event handler for the double click (empty method’s body). The result if a single click is obvious, but what will happen if user double clicks the check box (or the other CButton representation)? There are two possible answers (assuming the check box was unchecked initially):

  1. Check box will be checked, and then unchecked – a simulation of a double (single) click
  2. Check box will be checked only – one action takes place now

Continue reading ‘MFC: CButton and how ON_BN_DOUBLECLICKED message map works’

TFS vs. Subversion

Update, 2010-10-23 Note: After reading discussion on Martin Hinshelwood’s blog, I’ve decided to state clear I’m writing here about TFS 2008. Some of the points might not be relevant to TFS 2010.

I’ve been using both Subversion and Team Foundation Server (TFS). Because I first used Subversion and started using TFS afterwards, I had to get used to TFS flavors. I think TFS is great but to be honest there were a few things I missed from Subversion and a few things that really annoyed me when I started using TFS.

So, this is a list of strong and weak points of TFS from the perspective of a developer who switched to it after using Subversion.

Continue reading ‘TFS vs. Subversion’

Windows Error Reporting – first steps in postmortem debugging – how to collect mini dump?

Note: What is described below applies to Windows Vista x64 (at least I used such OS). I’m not going to describe what to do with a mini dump – how to analyze it in a debugger (e.g. in Visual Studio); such information can be found in a very good article at CodeProject. What I’m going to present here is how to set up Windows Vista so that mini dumps are created when an application crashes, and enforce they are stored locally on the machine on which that happened.

I believe every developer uses debugger while product creation. However it’s also possible to debug the application after it’s delivered to the client. One of such techniques is postmortem debugging – the act of debugging the memory dump of a process, which is stored in a special file (not human readable).

Microsoft has created a special service – Windows Error Reporting. Prior to Vista, Dr. Watson was default Windows application debugger that created crash dumps. Starting with Vista, Microsoft has replaced Dr. Watson with a new, improved mechanism. In short (supposing Windows Error Reporting is enabled), if an application crashes a mini dump (representation of the state of the process) is created. Mini dump is much smaller but still provides plenty of needed information. Depending on settings, a mini dump can be sent to Microsoft for further analysis. This is default behavior which, at least in my case, resulted in no mini dumps stored locally on the machine where the crash took place.

Continue reading ‘Windows Error Reporting – first steps in postmortem debugging – how to collect mini dump?’

How to abort load test when its scenario fails?

By definition a load test is supposed to simulate many users accessing a server at the same time. It consists of series of iterations, which can be either Web tests or unit tests. Each operation is repeated the defined number of times for each virtual user.

A load test completes with status ‘Completed’. If one needs to learn more details on the run, they should open the result file (trx) and read the statistics. Now, in real world something can go wrong with either the infrastructure or one of the system components. Let’s say that one of the element in a long Web test fails for a reason. In such case you would rather not wasting time analyzing the result of the test to find it out only ten, but write it off automatically.

Continue reading ‘How to abort load test when its scenario fails?’

IIS: Disable the web site and display generic app offline information

Deployment of a new version of a site is a very tricky/risky procedure. At some point (i.e. until deployment is not completed) your service will work not as it is supposed to, which can result in reset session, HTTP errors displayed, etc. Whatever the result is it can really discourage the users of your service and, let’s be honest, will not look very professional (if not lame…).

That’s why at the time of deploying the changes, you probably should temporarily switch off the service and display the appropriate message so that the user knows the web site is being updated, and that is happening now.

Now, if you are hosting the service on IIS this is very simple to achieve. All you need to do is copy app_offline.htm to the root directory of your web site. Once the file is in place, it will be served to the user as a response to any request to your web site. Once you’re done with deployment, remove that file and the updated service will start working again.

LoadTest: MethodAccessException Microsoft.VisualStudio.TestTools.WebTesting.WebTest.set_Outcome

I had a load test that used a coded web test. At some point the coded web test changed, i.e. this line was added: Outcome = Outcome.Fail;.

After this change the test stopped working – it always ended with error message: ‘User aborted test run’. Apart from that each iteration of the web test produced MethodAccessException: Microsoft.VisualStudio.TestTools.WebTesting.WebTest.set_Outcome(Microsoft.VisualStudio.TestTools.WebTesting.Outcome).

Solution

The reason for the problem was I was using Visual Studio TS 2008 without SP1. Once I installed the SP1, which must have updated mstest, the test started running successfully again.

The key point here is before SP1 Outcome was read-only property, which I learned there.

How to invoke a common coded web test method from GetRequestEnumerator()?

It’s a fact that coded web test methods give more flexibility to the developer, i.e. common code reuse. So let’s create a coded web test in whose GetRequestEnumerator() method you want to call a common method which tests some other requests. Let’s make it look as GetCommonRequests() in the example below:

public class AWebTest : WebTest
{
    private IEnumerator<WebTestRequest> GetCommonRequests()
    {
        WebTestRequest req1 = new WebTestRequest("http://google.com");
        yield return req1;

        WebTestRequest req2 = new WebTestRequest("http://google.com");
        yield return req2;
    }

    public override IEnumerator<WebTestRequest> GetRequestEnumerator()
    {
        WebTestRequest req = new WebTestRequest("http://google.com");
        yield return req;

        GetCommonRequests();
    }
}

You would expect to see three requests in the test result. You will see only one though…

Continue reading ‘How to invoke a common coded web test method from GetRequestEnumerator()?’