Tag Archives: .NET

Debugging and Breakpoints not working in Visual Studio 2015

If you are opening your old solutions in Visual Studio 2015 you may experience some problems with hitting breakpoints and debugging therefore debugging is not possible especially in Unit Test projects.

Solution
I found out that the solution (.sln) was the problem. I created a new empty Solution in VS 2015 added all existing projects and everything is working fine again.

Tagged , ,

WPF DateTimeControl – The Outlook-Style DateTimePicker control for WPF

WPF does not offer a DateTimePicker out of the box. The WPF toolkit contains a DateTimePicker control, but I dislike it’s look and feel with the up- and down buttons. So I wanted an Outlook-style DateTimePicker control that look like this…
DateTimeSample

You can embedd the control in the normal XAML way…

 <Grid>
        <StackPanel VerticalAlignment="Center">
            <local:DateTimeControl x:Name="dateTimeControl"/>
...

Here is a sample application containing all the code…
https://1drv.ms/u/s!AnjbhF0srlTbgq5WHia7vSfk7wzIMg

Tagged , ,

Async/Await Snipped: Ensure one-time execution

Think if you have some initialization code that you want to execute only once. Multiple threads could call in. Your code uses async and await keywords and you want to be able to await until it completes…

        Task _workerTask;

        object _workerSyncRoot = new object();

        async Task EnsureWorkerDoneAsync()
        {
            // ensure that the worker is executed only once
            lock (_workerSyncRoot)
                if (_workerTask == null)
                    _workerTask = WorkerAsync();
            
            // await the worker, if it has not
            if (_workerTask.Status != TaskStatus.RanToCompletion)
                await _workerTask;
        }
Tagged , , ,

Async/Await Snipped: Avoid multiple calls by using delays

When you work with async and await keywords in C#. You sometimes want to avoid unnecessary calls, that are caused by multi-threading. Here is a simple snipped that works fine…

Scenario: Last Wins

        Task _delayTask;

        async void StartWithDelay()
        {
            // keep a local copy and a member copy of the task
            Task delayTask = _delayTask = Task.Delay(1000);

            // await the delay
            await delayTask;

            // is it still the same task (or is there a new one)
            if(delayTask == _delayTask) 
            {
                // do your work here...
            }
        }
Tagged , , ,

Deploying and Debugging Windows 8 Apps on Microsoft Surface

Good testing is important when developing applications. So before you publish an app for Windows 8, it could make sense to test the performance and look and feel on a Surface RT device. As a developer using Visual Studio 2012 it is pretty easy to do this. With Visual Studio Remote Debugger Tools you can deploy and debug your application. Also this is the only way I know, to deploy an app to a Surface RT device without using the Microsoft Store.

Small Overview

The following is a small overview of how it works

1. Download Visual Studio 2012 Remote Debugger Tools

Power your Surface and download the tools for ARM devices and install it
http://www.microsoft.com/en-us/download/details.aspx?id=30674

2. Start Remote Debugger

Search in your apps on your surface and start Remote Debugger

Image

4. See Remote Debugger is running

You should note the name and the port for Visual Studio configuration.

Image

5. Deploy and debug

Now you can switch to your developer machine and configure Visual Studio to deploy and debug on your surface device.

Image

Expiration Date of Your Developer License

When your developer license on the Surface has been expired, you need to update the registration in the following way
– Start Powershell as Administrator
– Enter the following command: Show-WindowsDeveloperLicenseRegistration
This can also be useful, if you get the message: “Found 0 connections on my subnet.” in Remote Debugger Connections
Still no luck? Maybe it will help to switch your Wifi access point on and off -> works for me

More information

A good starting point with more detailed information can be found here…

http://msdn.microsoft.com/de-de/library/vstudio/bt727f1t.aspx

Tagged , , , , ,