Remote Debugging in Visual Studio – Part 1

Every Visual Studio developer has probably come across the need of Remote Debugging at some point during development. I too faced that situation.Visual Studio supports remote debugging from one computer to another. When you are doing remote debugging, the host computer can be any platform that supports Visual Studio on which you control the debugging process. The remote computer can be a 32-bit or 64-bit Windows or Arm platform on which the debugger is run. It ships along with all versions of Microsoft Visual Studio.

Fore more about setup and configure Remote Debugger please visit  How to: Set Up Remote Debugging

Debugging process is controlled from the host and the listener on the remote computer that executes commands sent from Visual Studio. Here the listener is Remote Debugging monitor (msvsmon.exe).

The next important thing is security. You can either perform debugging in NoAuthentication mode or in Windows Authentication mode. Windows Authentication mode requires the same account to be setup on the host and the remote compute and both usernames and passwords must be the same. NoAuthentication mode which allow all people to access your debugging monitor.

Once finished the configuration part, deploy the application and pdb files on the remote machine and begin with starting msvsmon.exe on the same. We can now either start the application under the debugger or attach the debugger to the already running process.

Let’s start with the first scenario : start the remote debugging by modifying the start project properties page

Debugger1

If you don’t have access to the application solution, then you need to use the application EXE file. From Filemenu choose Open->Project/Solution… and find the EXE file for your application. Select the newly opened project and choose properties. Fill the page with following values:

Debugger2

Pressing F5 will start the remote application, now you can debug application on the remote machine like how you debug application in the local machine.

My next blog is about :  How to Attach and Debug application in Cross Domain

Advertisement

Anonymous Types

Anonymous Types are one of the nice feature in .net framework and i have never seen this code snippet anywhere in my project. Anonymous Types enable you to create objects without writing a class definition for the data type. Instead, the compiler generates a class for you. The class has no usable name, inherits directly from Object, and contains the properties you specify in declaring the object. You create anonymous types by using the new operator together with an object initializer

Dim carID As Integer = 100
Dim carName As String = "Car Name"

Dim carValue = New With {Key carID, carName}

'Which is same as

Dim anotherCar = New With {Key .ID = carID, .Name = carName}
Console.WriteLine("CarID : {0}", anotherCar.ID)
Console.WriteLine("Car Name : {0}", anotherCar.Name)

Anonymous types contain one or more public read-only properties.You cannot declare a field, a property, an event, or the return type of a method as having an anonymous type. Similarly, you cannot declare a formal parameter of a method, property, constructor, or indexer as having an anonymous type.

.Net 4.5 ‘Delay’ Binding property

‘Delay’ is one of the coolest property which is introduced as a part of the series on WPF 4.5 new features.

As pointed out by MSDN, If you use a data binding to update a data source, you can use the Delay property to specify an amount of time to pass after the property changes on the target before the source updates. For example, suppose that you have a Slider that has its Value property data two-way bound to a property of a data object and the UpdateSourceTrigger property is set to PropertyChanged. In this example, when the user moves the Slider, the source updates for each pixel that the Slider moves. The source object typically needs the value of the slider only when the slider’s Value stops changing. To prevent updating the source too often, use Delay to specify that the source should not be updated until a certain amount of time elapses after the thumb stops moving.

<Window x:Class="WpfApplication6.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Height="166"
        Width="301">
    <Grid>
        <StackPanel>
            <Slider x:Name="ValueSlider"
                    Minimum="0"
                    Maximum="100"
                    Margin="20"
                    Height="25"
                    Value="{Binding ElementName=ValueText, Delay=500, Path=Text,Mode=TwoWay}" />
            <TextBox x:Name="ValueText"
                     Text="50"
                     Width="100"
                     Height="50"
                     FontSize="20"
                     HorizontalAlignment="Center" />
        </StackPanel>
    </Grid>
</Window>

Again, it’s a discrete addition to the WPF framework but it’s a useful one !