Windows 8.1 : How to boot on a VHDX disk


To create a dual boot on your physical PC:

1. Create a Hyper-V Virtual Machine with a bootable VHDX disk file.
2. Via Windows Explorer, mount the VHDX disk in Windows 8.1 (right-click on the .vhdx file and select Mount).
3. A new drive will app appear in Windows Explore (ex. with F: drive letter).
4. Start a Command Prompt As Administrator, and run “bcdboot F:\Windows“.
5. Check and configure the dual boot options via “msconfig.exe” (tab Boot).
With msconfig, you can delete this bootable disk if you want.

Dual Boot

Posted in Hyper-V, Tips and others

SQL Server Reporting Services (SSRS) – Reports Transfert tool


In many project where I use SSRS, I create three folders for Development, Acceptance and Production environments. By default, Microsoft does not provides a solution to download and update all reports in one step.

So, I created a open source tool (in C#) that allows to connect on a SSRS server and retrieve all files in your PC (reports, DataSet, DataConnection, images, etc.). You can easily modify these XML files. And finally, this tool allows to transfer all of these files on the server or another SSRS server.

Source code and executable: https://github.com/dvoituron/SsrsReportTransfert

Tagged with: ,
Posted in Uncategorized

How to solve “Hypervisor is not running” error?


If like me, you use often HiPer-V to validate products or to develop in the same environment as your customer, so you could be receive this error : “XXX could not be started because the hypervisor is not running.

First, check if you have enabled the DEP setting in BIOS (https://technet.microsoft.com/en-us/library/cc731898.aspx).

Next, if this doesn’t work, start a Command Prompt in Administrative mode and run the following command.

bcdedit /set hypervisorlaunchtype auto

You can check the parameter has been set by running the following command.

bcdedit /enum

HiPerV

Reboot your machine and your virtual machines should now be working.

Posted in Hyper-V, Tips and others

SQL Server 2008, 2012, 2014 download links


In a previous blogs, I’ve explained where to download SQL Server 2008 and 2012 Express.
Bellow, you will find all download links for SQL Server 2008, 2012 and 2014.

SQL Server Express

LocalDB

Database Only

Management Studio

Database with
Management Tools

Database with
Advanced Services

Windows Services

 

X

X

X

X

SQL Server Database Engine

X

X

  

X

X

SQL Server Management Studio Express

 

  

X

X

X

Full-Text Search

 

  

  

  

X

Reporting Services

 

  

  

  

X

Download 2008
… SP3 here

 

84 MB
X86 – X64

172 MB
X86 – X64

224 MB
X86 – X64

515 MB
X86 – X64

Download 2008 R2 SP2
… More on Microsoft

 

120 MB
X86 – X64

160 MB
X86 – X64

340 MB
X86 – X64

1 GB
X86 – X64

Download 2012 SP1
… More on Microsoft

34 MB
X86 – X64

145 MB
X86 – X64

930 MB
X86 – X64

1 GB
X86 – X64

1.9 GB
X86 – X64

Download 2014
… More on Microsoft

40 MB
link

190 MB
link

680 MB
link

840 MB
link

1.1 GB
link

 

Warning: Backup files generated with 2008 R2 are not compatible with 2008 version.
For more information about LocalDB, read this article and this SQL Tips.
A list with all SQL Server Builds is here.

Posted in Uncategorized

TFS – How to set the default Work Item State to “Associate”


By default, in Visual Studio, when you want to check-in some pending changes, the default State value of related work items are to “Resolved”.
You can change this default value to “Associated” to avoid some suprises ;-) :

  1. Close Visual Studio
  2. Execute RegEdit
  3. Go to the path [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl\Behavior]
  4. Set this key to False : ResolveAsDefaultCheckinAction = False
  5. Restart Visual Studio.

TFS Associate Sample

Posted in Team Foundation Server, Tips and others

How to bind to a Grouped Items ViewModel with sample data


In MVVM development, you need to define some items collections bindable to your User Interface (View).
First, you must create your collection and items, next, you can create some samples and finally you need to bind these objects to your View (UI).
Since Visual Studio 2013, it’s possible to create your Views and bind data directly in the Visual Editor (without know XAML).

All of that is available for Windows WPF, Windows Phone 8.1, Windows Store Apps, or Windows Universal Apps.

In the following example, I create all classes and XAML code from scratch. This example is a list of contacts grouped by letter’s category.

1. Create the ViewModel

First, we need write all items and collections classes like that.

The following code defines these 3 classes.

using System;
using System.Collections.ObjectModel;
namespace MyApplication.ViewModel
{
    public class ContactsViewModel
    {
        public ContactsViewModel() { this.Groups = new ObservableCollection<ContactsGroupViewModel>(); }
        public ObservableCollection<ContactsGroupViewModel> Groups { get; set; }
    }
    public class ContactsGroupViewModel
    {
        public ContactsGroupViewModel() { this.Items = new ObservableCollection<ContactsItemViewModel>();  }
        public ObservableCollection<ContactsItemViewModel> Items { get; set; }
        public string Letter { get; set; }
    }
    public class ContactsItemViewModel
    {
        public string LastName { get; set; }
        public string FirstName { get; set; }
    }
}

2. Fill the ViewModel with sample data

In the section 3 (below), we’ll use a sample data items to bind with our User Interface… in design mode and/or in runtime mode.

First, create a XAML file with a reference to your ViewModel to easier fill sample items.

<SampleData:ContactsViewModel
          xmlns:SampleData="using:MyApplication.ViewModel" 
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <SampleData:ContactsViewModel.Groups>
        <SampleData:ContactsGroupViewModel Letter="A">
            <SampleData:ContactsGroupViewModel.Items>
                <SampleData:ContactsItemViewModel LastName="Voituron" FirstName="Denis" />
                <SampleData:ContactsItemViewModel LastName="Dubois" FirstName="Anne" />
            </SampleData:ContactsGroupViewModel.Items>
        </SampleData:ContactsGroupViewModel>
    </SampleData:ContactsViewModel.Groups>
</SampleData:ContactsViewModel>

And create an associated class to load this XAML file in memory.

using System;
namespace MyApplication.SampleData
{
    public class ContactSample : ViewModel.ContactsViewModel
    {
        public ContactSample()
        {
            Uri resourceUri = new Uri("ms-appx:/SampleData/ContactsSample.xaml", UriKind.RelativeOrAbsolute);
            Windows.UI.Xaml.Application.LoadComponent(this, resourceUri);
        }
    }
}

3. Draw your User Interface (View).

a. Create a new Page with a ListView.

Add a new Blank Page (right-click / Add / New Item) and drop a ListView or a GridView in your main screen (from the toolbox).

b. Create a CollectionViewSource in your page.

In your new Page, go in the top of XAML file to add this code (a CollectionViewSource and a DataContext):

<Page … 
    xmlns:sample="using:MyApplication.SampleData" />
<Page.Resources>
    <CollectionViewSource x:Key="ItemsGrouped" IsSourceGrouped="True" ItemsPath="Items" Source="{Binding Groups}"/>
</Page.Resources>
<d:Page.DataContext>
    <sample:ContactSample />
</d:Page.DataContext>

Note that d:Page.DataContext defines a DataContext to our ContactSample data, only in Design Mode. So, in runtime you can fill your ViewModel with real data.

That’s all for coding: all of following steps will be only in visual mode in Visual Studio.

c. Set the ListView.ItemsSource

Switch your interface from XAML to Design mode (menu View / Designer), and select the ListView control.
Press F4 to display the ListView control properties and click on the square next to ItemsSource property, and choose the Create DataBinding command.
Define the Binding type to a StaticResource, select your resource ItemsGrouped and click on OK.

d. Define a look for the HeaderTemplate.

Right-click on the ListView and choose the command Add GroupStyle. So, the command GroupStyle / HeaderTemplate is available.
Before to draw visually your Group Header box, hide this listview ;-) For me, it’s a bug in Visual Studio.

And now, go to edit the current Header Template.

And draw as you want: add a Grid and a TextBlock… and bind the
TextBlock.Text property to the Letter property of your SampleData.Groups collection item.

e. Define a look for the ItemTemplate.

Right-click on the ListView and choose the command Edit ItemTemplate / Create Empty. And choose a name for this ItemTemplate (ex. ContactItemTemplate).

And draw as you want (a Grid, 2 TextBlock)… and bind the TextBox.Text to LastName and FirstName of a contact item.

That’s all… you can unhide the ListView or run this application to display a contact list grouped by letter. Of course, in runtime, you need select correct data (not sample from xaml) and sort all contacts by first letter.

Tagged with: , ,
Posted in Formation, MVVM

Asynchronous Simplified


Introduction

For recent developments, users want reactive graphical interfaces, even if you need to recover data from external sources (ex. with web services).
The best solution is to create asynchronous operations to let a responsive UI.
Since the Framework 4.5, Microsoft offers a new and easy way to use asynchronous methods.

Basically, you can create a software with two methods:

  • void LongMethod() to run something that takes a lot of time (ex. 2 seconds).
  • string QuickMethod() to run something that takes little time (ex. 1 second).

public void LongMethod()
{
    System.Threading.Thread.Sleep(2000);
}
public string QuickMethod()
{
    System.Threading.Thread.Sleep(1000);
    return "ABC";
} 

1. Synchronous methods

when you start successively these two methods, of course the User Interface freezes until the procedure is completed.

MyLongMethod();
MyQuickMethod();

And the execution traces will be… and my UI not responding.

 

2. Classic Asynchronous methods

To avoid the UI freezes, you can run these methods into two Threads, via Task.Factory.StartNew or simply Task.Run (see difference on PFXTeaml’s Blog).

Task.Run( () => MyLongMethod() );
Task.Run( () => MyQuickMethod() );

And the execution traces will be… My UI is responding, but of course, you can see a problem: the Main Finished come before each method Finished steps.

3. async / await methods

The best solution, is to use the new async / await keywords. In this case, my methods will be run in different threads (versus my UI) and they wait each finish to continue my main program. And note that, by convention, a method called asynchronously will be suffixed by the Async keyword.

async void Go()
{
   await MyLongMethodAsync();
   await MyQuickMethodAsync();
}

And the execution traces will be… My UI is responding, and the program workflow is correct.

Quick Tips

Unfortunately, if you try to update a UI component or a Collection binded to your UI, from a thread, you’ll receive a NotSupportedException.

You can solve that with two different methods (for a WPF application):

  • The full parameterized method, where you can define a priority level and a timeout beyond which the process will be canceled.

Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, 
                                      TimeSpan.FromSeconds(1), 
                                      new Action( () =>
   {
      // Method to execute in the UI Thread.
      this.ConsoleItems.Add(new ConsoleItem(text, level));
   }
));

  • The light method: before run your asynchronous methods, keep a reference of UI (SynchronizationContext.Current), and next call the Send method.

public SynchronizationContext UIContext { get; set; }

UIContext.Send((state) => 
{
   // Method to execute in the UI Thread.
   this.ConsoleItems.Add(new ConsoleItem(text, level));
}, 
null);
 

 

Finally, if sometime you need to run some methods in a Thread different of UI Thread, but you must ensure that all of these methods will be run in the same Thread (only one). So, download the StaTaskScheduler class wrote by Microsoft and available in a ParallelExtensionsExtras package and write your async method like that:

StaTaskScheduler _sta = new StaTaskScheduler(1); // 1 is the NumberOfThreads

Task<TResult> RunTask<TResult>(Func<TResult> function)
{
   return Task.Factory.StartNew<TResult>(function, CancellationToken.None, TaskCreationOptions.None, _sta);
}

Posted in Formation, Thread, Tips and others
Follow me
   RSS Feed    Twitter    Linked In

Write you email address to subscribe at this blog and to receive new posts by mail.

Join 10 other followers

Who I am?


Follow

Get every new post delivered to your Inbox.