February 12, 2013

Deactivate and Detach BindingExpression problem

I was trying to bind an BitmapImage to WPF’s Image.Source property.

Somehow the image kept not showing up so I added some WPF binding diagnostics:

xmlns:trace="clr-namespace:System.Diagnostics;assembly=WindowsBase"

This how my Image control looked like at the end:

<Image Source="{Binding FrontImage, trace:PresentationTraceSources.TraceLevel=High}" Initialized="imgFrontScan_Initialized" />

Looking at the Output window I saw Deactivate and Detach events for BindingExpression like the ones below:

System.Windows.Data Warning: 75 : BindingExpression (hash=33476626): Deactivate
System.Windows.Data Warning: 99 : BindingExpression (hash=33476626): Replace item at level 0 with {NullDataItem}
System.Windows.Data Warning: 59 : BindingExpression (hash=33476626): Detach

It took me few hours to find out what is happening but it finally hit me when I read that any change of DataContext will cause binding to detach.

In my case I have implemented event handler imgFrontScan_Initialized handing the Initialized event. In there I was creating a dynamically generated image and getting it assigned to the image’s Source property. This made DataContext to change and effectively detach the binding.

The simple solution was just to remove the event handler as I did not really needed it.

I hope this will save you few hours of debugging Smile

November 02, 2011

Running TFS Agents in the Cloud

At DevReach 2011 I did session on Load Testing in the Cloud together with Anton Staykov. We spent huge amount of research to prepare this session and I would like to share some of my experiences here. The result of having Visual Studio ALM MVP and Windows Azure MVP both work on same project is just outstanding!

In Visual Studio 2010 you have the possibility to record web performance test that records all the packets that are being sent to the web server and then replay the complete recording. You can also “encapsulate” the web performance into a load test and run the same web test thousands of times instead. This will generate huge utilization to your web server but it also puts a great demand to your test infrastructure in terms of hardware resources. Usually web servers are designed to handle great amount of traffic. You will need at least the same or even more hardware resources to generate enough load to your web server so you can measure peak/stress conditions.

Visual Studio allows you to create “rig” of one TFS Controller and multiple TFS Agents that will help you distribute the load over separate test machines. An agent must be installed on each test machine and each agent is registered with only one controller.

In our scenario we decided to showcase what is the HTTP latency impact using real Internet connection. We decided to place TFS Agents in the cloud (Windows Azure) and use them to generate HTTP traffic with real latency. The thing with the latency is that you cannot really emulate it. You can emulate send/receive delays and I believe this is how it is done with the Network Emulation in Visual Studio. However there is just no way to tell the packets how fast they should move on the wire. And we wanted to get the real picture. A thanks goes to my good friend Richard Campbell for sharing this idea and other precious tips.

Additional benefit that you get by placing the agents in the cloud is that you have geographical distribution using different Windows Azure datacenters all over the world. This is crucial for our demo as we want to show real HTTP latency and the best way to do that is to have geographically dispersed test agents all over the world.

With Windows Azure you can elastically size your installation on demand. This means that we can easily fire up 100 agents that will generate load to our web server, use them for few hours and them close them down. This is a great opportunity to scale your test infrastructure and pay for only what you are using. It is worth mentioning that unlimited number of virtual users is possible if your company has MSDN Subscription with Visual Studio Ultimate edition. This feature comes with the Visual Studio 2010 Load Test Feature Pack. A single license of the Ultimate edition is enough to enable this feature pack. This feature pack is actually a license key that you add in TFS Controller virtual users dialog box. Just for comparison – unlimited virtual users in other load testing solutions usually cost 6 digit amounts of cash, while the price of VS Ultimate with MSDN is much more affordable.

And last, having external clients hitting your web farm infrastructure is really the only way you can test how good your load balancer is working. And if it is working properly at first place. One hint – all instances from a single deployment (that is instances of the role located in one datacenter) end up using the same external IP. This is important to know from the load balancing prospective. So you must deploy your test agent role to multiple datacenters, use multiple separate deployments or have a special HTTP header tag generated in your web test. The first two techniques does not require configuration on the load balancer side but are pretty limiting in terms of unique IPs that can be used. The third technique requires load balancer to be configured to identify this custom HTTP header and apply client affinity based on that.

In short here is what we do. First record a web performance test using Visual Studio, then create load test that contains the recorded web test. The web performance test should hit the web server under test. You can easily change the domain name recorded in the web test using the Parameterize Web Servers feature in Visual Studio. This will extract the recorded domain name in a variable that is easy to change and switch to other web server. It will allow you to switch between staging and production environment pretty easy later on. After that we select the test to be run executed remotely and specifying the test controller we want to use. As we execute the load test now, Visual Studio sends all metadata about our load test scenario to the controller. The controller queries all available agents and sends them instructions on how to execute the load test. The controller is also responsible for weighting the number of tests executed on each agent. Agents replay the recorded web test steps and generate HTTP requests to our web server. The result of the execution of each test is send back to the controller, which in turn sends back the collected data from all agents to the Visual Studio. Controller is also responsible for collecting performance counters from the system under test i.e. the web server. All data that the controller receives can be stored in database and reviewed some time later.

When the load test complete all received data gets aggregated and you will get nice summary of what has been done during the load test. Part of the summary is shown below. Detailed data is also available in different tabs.

Overall Results
Max User Load 50
Tests/Sec 0.017
Tests Failed 0
Avg. Test Time (sec) 111
Transactions/Sec 0
Avg. Transaction Time (sec) 0
Pages/Sec 1.50
Avg. Page Time (sec) 27.7
Requests/Sec 5.87
Requests Failed 0
Requests Cached Percentage 35.5
Avg. Response Time (sec) 7.27
Avg. Content Length (bytes) 245,429

How we did it?

We used Worker Role in Windows Azure to install the TFS Agent bits. The thing with Azure is that you can fire up plenty of machines (basically unlimited number) that will have the agents installed. The Worker Role serves as a “template” for new instance invocation. However you need to have a fully automated process of installing and configuring everything that’s required. The reason for this is that when a new instance (a new machine) of your worker role is starting up, it should do everything by itself. No manual configuration steps should be involved. Azure may also “heal up” your machine – it is a process of replacing your unhealthy old instance with a brand new and clean instance of your role “template”. Installation of TFS Agent bits is pretty easy. It is a simple copy process of all required binaries. There is a configuration step that needs to be executed at a later stage to get it all configured. This step takes about few minutes to get done.

In addition to the TFS Agents bits, you will want to install Visual Studio 2010 SP1. This is a time consuming process of about 20-30min depends on the Azure hardware configuration that you are using. We used SP1 Web install as it is able to download all required binaries from the Microsoft Download Center directly. Since all ingress (incoming) traffic in Azure is free the size of the SP is something we do not really care about. Automated installation of SP1 bits was the step I spend huge amount of time. One big gotcha is the location of TEMP folder in Windows Azure. By default the TEMP folder size is limited to 100MB. I had to create a local storage with enough space to fit the bits downloaded by VS SP1 and replace the existing TEMP folder environment variable to the location of my local storage folder. After all SP1 bits are installed a restart is required to finalize the installation process.

When the instance is up and running you must also run TFS Agent configuration tool. This step installs TFS Agent as a service or as an interactive process on the machine. The latter is needed if you want to execute CodedUI tests on the agent. If you are planning to run web and load tests only, install the agent in service mode. The agent also gets registered with the controller. The registration process requires that port 6901 is open on the controller machine and port 6910 is opened on the agent. The configuration process makes sure that firewall is configured properly. However you also need to make sure Azure is aware of your intend to use these ports. Internal Endpoints on the web role must be defined to allow port 6910 (that is the agent communication port).

So far I only discussed how to configure TFS Agents on the cloud. In order to get the full rig running you also need TFS Controller running. My recommendation would be to have the controller installed in the same network where the web server(s) are located. The controller collects performance counters from the web server. This technology uses UDP as transport protocol and UDP is not supported in Windows Azure. So if you choose to place the controller in the cloud, close to the agents, you will lose perfmon data collection from the system under test i.e. the web server. On the other side when the controller is running on premises, i.e. close to the web server, a lot of data transfer will be charged from the agents to the controller. Still I prefer the first option so I can have the most data out of it. Perfmon data from the system under test also gets validated by built in validation rules within Visual Studio and different thresholds are applied. This is a really powerful way to get some guidance of how good or bad your web server is performing by applying warning and critical thresholds values. All rules are customizable and you can built new ones or edit the existing ones.

There is one final glue to stick this all together – it is Azure Connect. Connect is Microsoft implementation of VPN server\client tool that works on Windows Azure. Currently Azure Connect is CTP only but it works very stable. With Azure Connect we put agents in the cloud and the controller on premises into one Endpoint group. At the point you get the agent role and controller set up in one endpoint group they can connect to each other using IPv6. The web server itself does not have to be added to this group as we are sending HTTP requests using its public domain name.

Now that we have everything scripted and automated, the whole process of firing up a new instance of our agent role and registering the agent with the controller takes roughly about 1 hour. This is basically because SP1 install is time consuming. However 1 hour is still pretty good accomplishment. You can start hundreds of agents by a simple Azure deployment configuration change and you are ready to generate insane amounts of requests hitting your web farm.

Is your web server ready to handle the holiday traffic? Contact us to find out the answer. Within 1 hour we can load test your web farm and see if it is “holiday” ready.

September 28, 2011

Unhandled Exception System.BadImageFormatException

Today I tried to run a small .NET application, that I am using for more than 5 years already. It serves a small but very important purpose in my personal data management. I guess the author of this app, which I have great respect of, will be really surprised to find out anyone is still using his app out there.

When I started the application I’ve got the following error message:

image

In case you are missing Debug the program option you need to install some JIT debugger like Visual Studio, WinDbg or other. I will get into details of how this works in Windows in another post.

If you open the details of this crash you will get almost no meaningful information:

Description:
  Stopped working

Problem signature:
  Problem Event Name: APPCRASH
  Application Name: pwm.exe
  Application Version: 1.5.0.10
  Application Timestamp: 48014697
  Fault Module Name: KERNELBASE.dll
  Fault Module Version: 6.1.7601.17651
  Fault Module Timestamp: 4e21213c
  Exception Code: e0434f4d
  Exception Offset: 000000000000cacd
  OS Version: 6.1.7601.2.1.0.256.1
  Locale ID: 1033

We can see from the above that the program stopped working (we’ve kind of knew that already) and that the exception goes from within kernelbase.dll. Given that I know upfront this is a managed application, having a crash at kernelbase.dll does not feel good.

I have Visual Studio installed already so I just selected Debug the program option and then Yes on Visual Studio Just-in-Time debugger dialog.

image

From the dialog box above you can now see the exception type in top level text saying: An unhandled exception (‘System.BadImageFormatException’) occurred in pwm.exe [3380].

Digging through MSDN does not help much either: Troubleshooting Exceptions: System.BadImageFormatException - A BadImageFormatException exception is thrown when the file image of a DLL or executable program is not valid. Make sure the file image is a valid managed assembly or module. This exception is thrown when unmanaged code is passed to Load for loading.

At this place I stopped for a moment. I didn’t want to go into the debugger if the problem is not requiring it. As a general rule, use the right tool for the right job. Or you might spent countless hours trying to solve the problem with the wrong tool.

Tip: In case you read my previous blog post you may want to try your SOS skills and debug the application using Visual Studio after all :) Chances are that you will get the following error after you run .load sos command: Unable to evaluate the expression. This error comes to say that at point of the execution of the program there is no managed code loaded yet. In short – loading sos does not make sense here and Visual Studio can not load the debugging extension. I am with you that a better error message should be provided.

So I have BadImageFormatException and MSDN saying that the image may not be valid. I tried restoring the files in the folder from my backup drive. That did not change anything though.

I also tried looking at the assembly binding log using Assembly Binding Log Viewer aka FUSLOGVW. One of my theories was that the machine was missing some of the .NET binaries. Fusion log showed that the problem was situated in an assembly called NativeHelpers:

image

Double clicking on the particular trace, give you more details on the problem:

The operation failed.
Bind result: hr = 0x8007000b. An attempt was made to load a program with an incorrect format.

In case you want to know more about Fusion log viewer please read the all time blog post from Suzanne Cook - Debugging Assembly Loading Failures. And in order to keep this post short and focused I will write more about Fusion log viewer in another post.

Then I asked myself a question – what changed that it was working before and now it is not working. Well, that was obvious to tell, at least to me. Last night I finally managed to reinstall my laptop with fresh new installation of Windows 7. However this time I decided to go with x64 edition as opposed to the x86 version. The last one I was running for more than an year. After small memory upgrade it was about the time for me to make the switch.

Suddenly it occurred to me that BadImageFormatException might actually mean that the assembly is not built to run in x64 environment. So I decided to try a small trick. There a tool in .NET Framework SDK that allows you to change the bitness of the assembly. It is called CorFlags.exe and is usually located at C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin. Your mileage may vary.

So I went ahead and run corflags.exe /32BIT+ pwm.exe. That is the main executable of the application. The parameter /32BIT+ sets the 32 bit of the assembly. Short example on how to use corflags with 32BIT parameter you may find in the Corflags.exe in 64-bit Environment blog post from Matevz Gacnik.

Volla! My application got running and life’s good again. I happen to have the sources of the app so I loaded the project in Visual Studio just to verify the root cause of the problem. I found out that NativeHelpers is a managed C++ project. As such this project is built using the Win32 configuration. Managed C++ projects doesn’t have Any CPU configuration type as C# managed projects do. Needless to say all the rest of the projects were configured as Any CPU type. Hence CLR started pwm.exe as x64 process (like the OS type it was running on) and then CLR tried to load NativeHelpers as a x86 assembly. That causes file format incompatibility and BadImageFormatException is thrown by CLR.

What does it mean to you as a developer – learn what project configurations are for in Visual Studio. Learn how to deal with deployment on x86 and x64 platforms. Also learn what Any CPU means. A nice resource wrapping up all these topics is located at Moving from 32-bit to 64-bit application development on .NET Framework blog post from Gaurav Seth. Pay attention to the resources at the end of the blog post too.

September 25, 2011

TfsComProviderSvr has stopped working

Some time ago I got this error on my machine: “TFS Power Tool Shell Extension (TfsComProviderSvr) has stopped working”. My first reaction to handle this problem would be to reinstall TFS Power Tools 2010 where the problem was obviously located. However I decided to leave the problem so I can write this blog post.

It took few months and hundreds instances of the dialog box below though:

image

This dialog box is part of Windows Error Reporting (WER) which I am about to cover in additional post. One thing you should really do when you see this message is to open the details using the “View problem details” panel at the bottom of the dialog box. In my case this provided me with the following information:

Problem signature:

  Problem Event Name:        CLR20r3

  Problem Signature 01:        tfscomprovidersvr.exe

  Problem Signature 02:        10.0.30319.0

  Problem Signature 03:        4d6d4f92

  Problem Signature 04:        JOPSJ0BBDPTVPWWFWUIIWQ2SYBSSFGDF

  Problem Signature 05:        10.0.0.0

  Problem Signature 06:        4d6d4f78

  Problem Signature 07:        4b

  Problem Signature 08:        24

  Problem Signature 09:        System.NullReferenceException

  OS Version:        6.1.7601.2.1.0.256.4

  Locale ID:        1033

  Additional Information 1:        0a9e

  Additional Information 2:        0a9e372d3b4ad19135b953a78882e789

  Additional Information 3:        0a9e

  Additional Information 4:        0a9e372d3b4ad19135b953a78882e789

There is some vital information we can gather here. That is process name (tfscomprovidersvr.exe), process version (10.0.30319.0) and exception type (System.NullReferenceException). It is good enough to pass this information to the support team and request support. This is not our goal here though.

 

Let’s go ahead and debug the crashed program instead. You can see there is a Debug button as part of the dialog box. When click it, you will be presented with options to select a debugger by your choice. I have Visual Studio installed so I selected it and I got the Disassembly window opened in Visual Studio.

 

image

This window shows us one really important piece of information – the location where the exception has been thrown. The faulting method is Microsoft.TeamFoundation.PowerTools.TfsComProvider.Core.TfsCache.CachedServer.Dispose(). Unfortunately we do not have the pdb and source files (more on this in later post) so we can only see the assembly code. Unless we do some tricks.

 

Some debugging pros my ask – why in the world you did not use WinDbg to debug this managed code instead. I personally also like WinDbg much more when it comes to debugging IL and assembly code. There is one thing that is really easy and straightforward to get from within Visual Studio. Just see the Locals window below:

image

We can now browse through the exception and this objects and see their member variable values. Also hovering over a symbol name, if resolved, will show its value in a tooltip. Pretty easy, right?

Open the Threads window to see where our code is executed. If Threads window is missing for you, go to Debug\Windows and select Threads.

image

Similarly you can open Parallel Stacks window:

image

And also the Call Stack window:

image

All these windows come to show you that the code is currently executed in the CLR Finalizer Thread.

So we’ve seen the assembly code, local variables and stack info. What should we do next? We can give Visual Studio debugger some help in order to digest the assembly code and make it more meaningful to us.There it comes SOS.dll. SOS is a debugger extension that have the capability to read and parse CLR structures and IL code. It is intended to be used with WinDbg however since Visual Studio 2010 it can be also loaded inside Visual Studio also.

Open the Immediate Windows and type .load sos. Type !help to see the list of all SOS commands. Tip: Right click on the Immediate window and select Dock as Tabbed Document to open the window using the full IDE size. Now that we have SOS loaded, lets try to find more information about the code being executed.

Now let’s get the value of IP (Instruction Pointer) register using the Register window:

image

The IP register contains the address of the instruction currently being executed. Now that we have it, we can call SOS method !ip2md that will convert our currently executing address into a CLR method description object:

!ip2md 001E3EF9
MethodDesc: 00139b18
Method Name: Microsoft.TeamFoundation.PowerTools.TfsComProvider.Core.TfsCache+CachedServer.Dispose()
Class: 001b4ab4
MethodTable: 00139b74
mdToken: b18800b20600004b
Module: 00135614
IsJitted: yes
CodeAddr: 001e3ec0
Transparency: Safe critical

Now we have the MethodDesc address that we can use to decompile this method to IL using the !DumpIL command.

!DumpIL 00139b18
ilAddr = 003c38cc
IL_0000: ldarg.0
IL_0001: call CachedServer::get_IsDisposed
IL_0006: brtrue IL_0092
IL_000b: ldarg.0
IL_000c: ldc.i4.0
IL_000d: call CachedServer::set_IsConnected
IL_0012: ldarg.0
IL_0013: ldfld CachedServer::m_vcServer
IL_0018: ldarg.0
IL_0019: ldftn CachedServer::VCServer_PendingChangesChanged
IL_001f: newobj Microsoft.TeamFoundation.VersionControl.Client.Wo::.ctor
IL_0024: callvirt Microsoft.TeamFoundation.VersionControl.Client.Ve::remove_PendingChangesChanged
IL_0029: ldarg.0
IL_002a: ldfld CachedServer::m_vcServer

In case your IL skills are fading, another option is just to use Telerik’s amazing FREE tool JustDecompile (pun intended). It will show us the originating C# code instead and it will help you better understand the IL code above.

public void Dispose()
{
    if (!this.IsDisposed)
    {
        this.IsConnected = false;
        this.m_vcServer.PendingChangesChanged -= new WorkspaceEventHandler(this.VCServer_PendingChangesChanged);
        this.m_vcServer.GetCompleted -= new WorkspaceEventHandler(this.VCServer_GetCompleted);
        this.m_vcServer.CreatedWorkspace -= new WorkspaceEventHandler(this.VCServer_CreatedWorkspace);
        this.m_vcServer.DeletedWorkspace -= new WorkspaceEventHandler(this.VCServer_DeletedWorkspace);
        this.m_vcServer.UpdatedWorkspace -= new WorkspaceEventHandler(this.VCServer_UpdatedWorkspace);
        GC.SuppressFinalize(this);
        this.m_isDisposed = true;
    }
}

Ok, so far so good. But how do we find out where exactly this application crashed? Here it gets a little hairy as there is no 1:1 way to tell that. The best thing we can do is to compare the source code (IL or C#) with the actually assembly code. Here is part of the assembly output taken from the Disassembly window:

00000000  push        ebp
00000001  mov         ebp,esp
00000003  push        edi
00000004  push        esi
00000005  mov         esi,ecx
00000007  cmp         byte ptr [esi+1Dh],0
0000000b  jne         000000FC
00000011  mov         ecx,esi
00000013  xor         edx,edx
00000015  call        FFFFF130
0000001a  mov         ecx,71F8F8B0h
0000001f  call        FFF3E1E4
00000024  mov         edi,eax
00000026  mov         ecx,dword ptr [esi+14h]
00000029  lea         edx,[edi+4]
0000002c  call        701EF170
00000031  mov         eax,13CAF8h
00000036  mov         dword ptr [edi+0Ch],eax
00000039  mov         ecx,dword ptr [ecx+34h]
0000003c  mov         edx,edi
0000003e  cmp         dword ptr [ecx],ecx
00000040  call        71D18A10
00000045  mov         ecx,71F8F8B0h
0000004a  call        FFF3E1E4

The highlighted line is where the debugger says the exception has occurred. That is instruction located at address 00000039. Based on the instruction located on this address, we can safely assume that the address referenced [ecx+34h] is not valid and that is the cause of the exception.

Now that we have the IL and C# source code, let’s try to map them to the faulting instruction using some simple and well known code constructions. This way we can see where ECX is being initialized and with what.

00000000 push ebp
00000001 mov ebp,esp
00000003 push edi
00000004 push esi
  public void Dispose()
{
00000005 mov esi,ecx
00000007 cmp byte ptr [esi+1Dh],0
0000000b jne 000000FC
IL_0000: ldarg.0
IL_0001: call CachedServer::get_IsDisposed
IL_0006: brtrue IL_0092
if (!this.IsDisposed)
{

00000011 mov ecx,esi
00000013 xor edx,edx
00000015 call FFFFF130
IL_000b: ldarg.0
IL_000c: ldc.i4.0
IL_000d: call CachedServer::set_IsConnected
this.IsConnected = false;
0000001a mov ecx,71F8F8B0h
0000001f call FFF3E1E4
IL_0012: ldarg.0
IL_0013: ldfld CachedServer::m_vcServer
 this.m_vcServer
00000024 mov edi,eax
00000026 mov ecx,dword ptr [esi+14h]
00000029 lea edx,[edi+4]
0000002c call 701EF170
00000031 mov eax,13CAF8h
00000036 mov dword ptr [edi+0Ch],eax
00000039 mov ecx,dword ptr [ecx+34h]
0000003c mov edx,edi
0000003e cmp dword ptr [ecx],ecx
00000040 call 71D18A10
IL_0018: ldarg.0
IL_0019: ldftn CachedServer::VCServer_PendingChangesChanged
IL_001f: newobj Microsoft.TeamFoundation.VersionControl.Client.Wo::.ctor
IL_0024: callvirt Microsoft.TeamFoundation.VersionControl.Client.Ve::remove_PendingChangesChanged

… .PendingChangesChanged -= new WorkspaceEventHandler(this.VCServer_PendingChangesChanged);
00000045 mov ecx,71F8F8B0h
0000004a call FFF3E1E4
IL_0029: ldarg.0
IL_002a: ldfld CachedServer::m_vcServer
 this.m_vcServer…

As you can see here, ECX is being initialized as part of the following statement:

this.m_vcServer.PendingChangesChanged -= new WorkspaceEventHandler(this.VCServer_PendingChangesChanged);

More specifically it holds the value for m_vcServer. Now if we go back to Visual Studio and hover at m_vcServer variable in the output of DumpIL command that we executed above, we will see that it is actually null.

image

At this point, if you are still reading this, let’s lean back and rethink. We have the Dispose method called by the Finalize method in a GC Finalizer Thread. Inside the Dispose method an object is being referenced and it is already null. Of course there is always possibility that someone just nulled this object explicitly. I do tend to believe that if this was the case, the programmer should also implemented the necessary null validation checks inside the Dispose method. Or may the object is not nulled explicitly but the GC already has collected it. I went ahead and refreshed my memory on Disposable pattern. And then it stoke me!

The IDisposable pattern is used to free managed and unmanaged resources. In order to allow code reuse a single method Dispose is usually implemented. The Dispose method gets invoked with a boolean parameter disposing to show if the method is called from Dispose directly or through Finalize method. If Dispose is called from Finalize, you are not allowed to call any managed objects as they might not longer exist. In our case the Dispose method neither has the parameter disposing implemented. As a result it ends up calling managed objects during finalization process and that generates the NullReferenceException.

Next steps – I am going to install the latest version available Team Foundation Server Power Tools August 2011 and will see if the Dispose pattern is implement correctly there. If not – I will use my MVP powers to reach the TFS product team at Microsoft and report the problem. I will keep you updated.

Tip: If you want to save the current program state and resume the debugging at some time later, you can do that by saving a memory dump file. Do that by opening Debug\Save Dump As… menu and select folder where to store the .dmp file. You can then open the saved .dmp file using Visual Studio 2010 File\Open menu. You will find out there is a nice Minidump File Summary window that was not available before. This type of debugging of the .dmp file is called postmortem debugging as opposed to the live debugging session that I did above. There are few things you should know about postmortem debugging like IL Interpreter for example. I will try to cover those in a separate post.

What does this mean to you as developer – read and learn the correct way of implementing IDisposable pattern. Go back to the books if you do not recall how it should be done. There is nothing wrong repeating what you have already learnt. The article DG Update: Dispose, Finalization, and Resource Management from Joe Duffy is the most comprehensive that I have read so far. It is great if you want to really go deep. If you just want to refresh your memory this blog post Notes on the CLR Garbage Collector from Vineet Gupta has a really nice recap of how GC works in CLR. It also have correct implementation of IDisposable pattern shown. At the end of the you will find tons (really tons) of resources on the memory management in CLR. Funny enough I even found IDisposable implementation in the Programming .NET Framework book that we did in Bulgarian back in 2005. The chapter of Memory and Resource Management was written by George Ivanov, fellow community lead who is now working at Microsoft Corp.

Rename TFS database

If you run in situation where you need to rename your TFS Team Collection database or TFS Configuration database, there are few simple steps how to do that.

First, why would you need to rename a TFS collection database? It happened to me, that my TFS upgrade from 2008 to 2010 failed at the first run so I ended up with a database name called Tfs_DefaultCollection_1. I really couldn’t live with that suffix in my database name, so I called TFS product group for help. Here are the steps:

Renaming Team Collection database:

1. Go to the admin console and take the collection Offline

2. Once the collection is offline proceed to SQL and rename the database. This may involve taking the database offline and back online in order to release any locks on the database.

3. Come back to the Admin console and select Edit Settings for that collection

4. In the edit settings dialog there is an entry for the database name

5. Change this to the new name

6. Wait for the action to complete (might take a while since this schedules a background activity to complete the operation)

Renaming TFS Configuration database:

1.  Close the admin console (we can't have UI open since everything is bound using the server model bound to the configdb - or at least it would add complexity)

2.  Stop the iis apppool (taking the server offline isn't enough because we're pulling the configdb out from under it and it's already loaded the connection string)

3.  Rename your config db.

4.  Go to tools and run tfsconfig help registerdb.  This ultimately just edits the web.config connection string but adds some checking for you around instanceid

Keep in mind that renaming any of the databases you need to plan some TFS downtime (around 3 min for renaming my team collection database).

September 09, 2011

DevReach 2011 Early Bird Offer


Специално издание на DotNetRocks, популярното интернет радио за .NET разработчици ще бъде записано на живо от DevReach 2011

Остават броени дни до края на ранната регистрация за DevReach 2011 на 15 септември 2011 г.

Шестото издание на DevReach, международната конференция за разработчици с Майкрософт технологии, ще се състои на 17 и 18 октомври 2011 г. в кино „Арена Младост” в София. Тазгодишното издание на DevReach привлича посетителите с горещи теми от света на технологиите (като Windows 8 например) и някои от най-популярните специалисти от света на .NET. Сред тях изпъква световно известния лектор и автор Скот Ханселман. Скот работи като главен програмен мениджър в Microsoft  и ще представи визията на Майкрософт относно инструментите, с които се изграждат уеб сайтове. Той ще открие DevReach и ще направи обзор на ASP.NET MVC 3 и 4, MVC Scaffolding, HTML5, NuGet, jQuery и др. Допълнително, ще представи и лекция за ASP.NET MVC Basic to Advanced. За почитателите на Скот, специално са подбрани и две лекции, в които гостите на конференцията ще могат да дискутират директно с него как да направят блога си по-добър и как да се справят с огромния обем информация, която заобикаля потребителите.

След Скот, Джеси Либерти – старши разработчик в екипа на Windows Phone, ще разкаже пред аудиторията за интригуващите функционалности в Windows Phone 7, които предстои да излязат съвсем скоро.

За първи път на DevReach ще гостуват и лекторите Гил Клиирън – Silverlight и Telerik MVP, Мартин Балиау – Windows Azure MVP, Charles Nurse – главен архитект в DotNetNuke. Лидерите на потребителски общности в Хърватска и Сърбия – Томислав Бронзин и Иван Павлович, ще представят лекции на тема Mobile BI и Behavior Driven Development.

Както всяка година, така и тази, DevReach ще включи интересни и лекции по най-важните и горещи теми – HTLM5, Windows 8 и създаване на естествен потребителски интерфейс. Това ще бъде направено от Тим Хъкаби, дългогодишен лектор на DevReach и Microsoft Regional Director, който ще открие втория ден на DevReach.

Силно застъпени ще бъдат и лекции на тема изграждане на модерен потребителски интерфейс с HTML5 и Silverlight, използване и приложение на ASP.NET MVC, оценка, проектиране и тестване на софтуерни проекти, както и уеб производителност.

За всички софтуерни предприемачи ще се състои специално издание на DotNetRocks, популярното интернет радио за .NET разработчици (www.dotnetrocks.com), което ще бъде записано на живо от DevReach 2011. За да бъдете част от тази жива дискусия е достатъчно само да посетите залата заедно с Ричард Кембъл,  Карл Франклин, Стивън Форте, Тим Хъкаби и Лино Тадрос.

Накратко за DevReach:
Сред лекторите са:
·              12 Microsoft MVPs
·              6 Регионални директори на Microsoft
·              6 INETA лектори (Speakers, Country and Regional Leaders)
·              10 автори на повече от 60 книги, публикувани от Microsoft Press, O'Reilly Media, Sams, Que, Wrox, Apress, Packt Publishing, Manning Publications и други 
·              Популярни лидери на потребителски общности с повече от 150 000 последователи

DevReach 2011 – технологии и теми
Сесиите са организирани в 5 основни потока (трака) с фокус върху:
·              Visual Studio 2010                           ASP.NET                               C#
·              Silverlight 5                                       HTML5                                Javascript
·              MS SQL Server                                  Linq                                      MS SharePoint 2010         
·              Windows Azure                                Cloud computing              Office365
·              Microsoft ALM Tools                       Agile                                      Behavior Driven Development
·              HTML 5 and Javascript – през перспективата на Windows 8
·              Ajax, CSS 3 and jQuery
·              HTML5 for Tablets & Mobile Devices
·              Разработка на мобилни приложения за iOS, Android and WP7

 Поглед към историята на DevReach
·              5 успешни издания, с нарастващ брой посетители всяка година
·              Повече от 550 експерти, посетили изданието DevReach 2010
·              Участници от повече 15 страни

За регистрация, моля посетете сайта на конференцията на адрес: www.devreach.com

За да получавате актуална информация за DevReach, следвайте ни във  Facebook, Twitter и LinkedIn.

July 09, 2011

Solving world’s problems today - Imagine Cup 2011

 

I am sitting in my hotel room looking straight at Times Square, New York City, listening to Steve Ballmer on CNN. Tomorrow about 424 competitors within 124 teams and representing 73 countries will showcase their solutions to solve some of the world’s toughest problems. These students made it to New York after many months of work and were selected among their peers. They represent best of the best. If they do not find the way to solve these problems, who else will?

For the third year I am proud to be part of the Microsoft’s Imagine Cup 2011 judge team. This time I arrived three days prior the event to have a chance to walk by in NYC. I met some fellow RDs here and had time to get known with USA history and culture. Seeing this amazing and very vivid city is truly amazing experience. It also led to think about some facts that our American friends do not pay attention too much at.

People in USA, and corporations here at large, must do better job preserving our planet. In NYC it is very important that stores and public places are very well air conditioned. NYC weather is extremely hot and humid in summer. However it is a common thing to see such stores keeping doors wide open and basically wasting energy and our planet’s vital resources. Should Imagine Cup finalist come up with a solution for that – I would surely like so. May be tomorrow we can even see some smart homes based on Kinect – I hope so.

Another fact – did you know that 1 of every 6th American is suffering from hunger by some extent? Washington Post says:

According to a new report by the U.S. Department of Agriculture, 17.4 million American families - almost 15 percent of U.S. households - are now "food insecure," an almost 30 percent increase since 2006. This means that, during any given month, they will be out of money, out of food, and forced to miss meals or seek assistance to feed themselves.

Just think about for a second how huge is hunger problem worldwide, even when one of the best economies is having a struggle. Will there be an Imagine Cup finalist to solve that problem – I bet you. As I walked over the Statue of Liberty and Brooklyn bridge the other day, I was thinking how good is walking compared to driving in terms of saved CO2. Our Imagine Cup finalist team from Bulgaria – Walk2Help is offering solution to help preventing hunger while saving CO2.

WP_000247

I am eagerly looking forward for Imagine Cup 2011 Awards. As the final launch of the NASA’s Atlantis was successful today we are looking forward to see what tomorrow will bring us. Tomorrow, technology will enable us to solve some of the toughest problems on the earth today.

May 21, 2011

TechEd North America 2011 Favorite Sessions

Here is a list of my personal favorite sessions from TechEd North America 2011. I thought it may be useful to you also.
The Future of Microsoft Visual Studio Application Lifecycle Management
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/FDN03>
Twenty Windows Tools You Never Knew Existed
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL205>
An Overview of the Microsoft Web Stack
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV349>
Building Business Applications with Microsoft Visual Studio LightSwitch
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV211>
Become a Wireshark Guru: 10 Hot Skills for Faster Troubleshooting
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL201>
Wiretapping 101: Catching Evidence on the Network
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/SIM201>
Metrics That Matter: Improving Lean and Agile,Kanban and Scrum
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR309>
Manual Testing with Microsoft Test Manager 2010
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV204>
Branching and Merging for Parallel Development
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV306>
Deep Dive into Microsoft Visual Studio Team Foundation Server 2010 Reporting
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV311>
Web Deployment Made Easy: Seriously
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV342>
The Architect
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR201>
Debugging a Dysfunctional Team
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR208>
Agile Estimation
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR202>
We Don't Need No Stinkin' GUI: Command-Line Capture Techniques (Remote Options)
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/SIM202>
Maximizing Windows 7 Performance: Troubleshooting Tips
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL316>
Test Automation with Microsoft Visual Studio 2010: Coded UI Tests and Lab Management
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV309>
Jason Zander Unplugged
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV212>
Demystifying Debugging with Microsoft Visual Studio Ultimate and IntelliTrace
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV320>
Why Web Performance Matters
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV344>
Debugging Pesky HTML5 Websites with F12 in Windows Internet Explorer 9
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV348>
Using Tests to Drive the Entire Software Development Lifecycle
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV350>
The Agile Buffet
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR306>
Lessons from Hackwarts Vol 1: Defense against the Dark Arts 2011 (Repeats on 5/19 at 10:15am)
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/SIM302>
Windows PowerShell Remoting: Definitely NOT Just for Servers
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL321>
Mysteries of Memory Management Revealed,with Mark Russinovich (Part 1 of 2)
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL405>
Mysteries of Memory Management Revealed,with Mark Russinovich (Part 2 of 2)
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL406>
Microsoft Visual Studio IDE Futures
<http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV326>

March 28, 2011

Microsoft Days 2011

Microsoft Days 2011 is going to be held this week, 30-31 March in Sofia, Bulgaria. This is the main Microsoft event for Bulgaria covering topics from development, IT Pro and Business. Registration closes today, so hurry up!

More about the event and speakers’ line up you can find here: http://www.microsoft.com/bulgaria/press/news_22032011.mspx.

It is worth mentioning some of the guest speakers though – Beth Massi, Rob Miles, Hadi Hariri, Daron Yondem, Karl Barett – guys that I personally know and respect a lot.

There is awesome free WP7 conference viewer also developed by Kiril Rusev, Imagine Cup 2009 finalist. Search for “MS Days” in Windows Phone 7 Marketplace.

I will be hanging out on Day 1 at the Community Booth on “Level –1” and if you have a chance come by to say hi and enter a raffle for 5 passes for DevReach 2011.

On Day 2 I will be presenting the following topics:

10:30 – 11:30 Practical Guide to UI Test Automation in Visual Studio 2010

User interface test automation has been always a much demanded functionality. Visual Studio 2010 introduces Coded UI tests that can be generated from manual test recording or record them on demand. Using data validations, build automation and using C# as a programming language, Coded UI tests are becoming the must have tool for delivering high quality software solutions.
Join this session to find out how to get it started and learn valuable tips that will save you time.
We will also explore more gems included in Visual Studio 2010 that allow us to automate Silverlight, run Coded UI tests with Firefox and edit them using graphical editor.

14:00 – 15:00 Practical Guide to Project Server and TFS Integration

The world of developers and project managers differs a lot. Developers concentrate on producing the best code, using the best tools and they hate reporting and planning. Project managers love to plan, track progress and hold developers responsible for all delays in the project plan. If you want to make both teams happy, the simple recipe is to make sure that the tools they are using can talk to each other. By integrating Team Foundation Server and Project Server project plan and reporting can be constantly monitored without having to prepare long status reports or leaving Visual Studio. Join the session to learn how to get this integration done with least amount of effort and frustration.

March 24, 2011

Silver Global Impact Award 2010

Believe it or now it has been an year since I last blogged. Funny enough my last blog post last year was about Visual Studio 2010 Official Launch. I still remember the journey for releasing Visual Studio 2010. As one of the Visual Studio ALM MVPs, it feels like I am part of the team releasing Visual Studio and Team Foundation Server 2010. The information exchanged on daily basis with TFS Product Group from Microsoft is just astonishing. Just this month Microsoft released Visual Studio 2010 SP1 and TFS 2010 SP1. And you can be sure that Visual Studio vNext aka Dev11 will completely blow your mind <grin>.

Many other things happened during 2010, which I would love to write them all but I can hardly do that in a single post. I also managed to get the technical issues that blocked me in first place for posting here for quite a long time. I will start keep up my blog up to date so you can read what’s cooking now and get more troubleshooting tips. On the other side, I do started to use Twitter (@kulov) where I tweet on a daily basis interesting news and useful links related to Microsoft technology. Follow me to keep in touch with more frequents updates.

There is one thing that really marks 2010 as a great year to myself. Just about a month after VS2010 was launched, I was extremely happy to hear that I got accepted in the Microsoft Regional Director program. I plan to dedicate a separate blog post on what this program means to me and to our community. For a quick introduction I will just say that this is a program for independent professionals, and I am not in employed at Microsoft in any form.

RD Logo PNG

“Regional Directors are members of an elite, worldwide group of technology thought-leaders known for their national and international speaking tours, their authorship of books, articles and blogs, and their business acumen. Regional Directors are well-versed on the totality of the software industry. They are recognized for their achievements in communicating the benefits of emerging technologies.”
Source: theregion.com

It is a great honor to be part of this group of really smart people some of them I worship since my very early years in programming.

Second half of the year 2010 I tried to align as best as possible with the RD program and continued to help our community grow. Although I couldn’t write here, I probably saw many of you on local and international events, or at least I reached you by email announcements. Some of the results are still to come in year 2011.

As result, at the MVP Summit 2011, in Redmond this February, Microsoft awarded me with the Silver Global Impact Award 2010 for my contribution to the Microsoft Regional Director Program.

WP_000124

Looking forward for even greater 2011!

Cheers!