[#VS2013] HowTo: Debug an external EXE file and some bonus track

Hi!

Today I have to use some part of my memory skills to remember how to debug an external exe file in Visual Studio. For this task I usually use WinDbg, however this scenario must be easier than that.

So a couple of steps for thos:

1. Open Visual Studio

2. Menu “File // Open // Project or Solution”

3. In the File System select the EXE file to debug

4. Done! press F5 or Run, and Visual Studio will run the app and it will attach to this process.

Very easy? If you take a look at the project properties, you’ll see the EXE path, working directory, etc.

image

Now bonus track, you can also launch a Profiling session into this external file.

image

The profiling process is the one you already knows, and is also great.

image

This option is great if you want to avoid WinDbg, however if you really want more details go to WinDbg world!

Greetings @ Munich

El Bruno

image image image Google

[#LEAPMOTION] HowTo: Show the number of fingers ever the Leap

Hello!

Today is going to be a quick post, I’ll change the console app for a WPF app to work with the Leap Motion. In this app, I’ll show how a gesture is detected by the sensor in addition to the amount of active fingers over the sensor. For this example I’ve used some information from in this post of the great Iris Classon to create the following listener

   1: using System;

   2: using System.Threading.Tasks;

   3: using Leap;

   4:

   5: namespace LeapWpf01

   6: {

   7:     public class ElBrunoListener : Listener

   8:     {

   9:         public void Sample(){}

  10:         public event Action<FingerList> OnFingersRegistered;

  11:         public event Action<GestureList> OnGestureMade;

  12:         private long _now;

  13:         private long _previous;

  14:         private long _timeDifference;

  15:

  16:         public override void OnInit(Controller controller) { }

  17:

  18:         public override void OnConnect(Controller controller)

  19:         {

  20:             controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);

  21:             controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);

  22:             controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);

  23:             controller.EnableGesture(Gesture.GestureType.TYPESWIPE);

  24:         }

  25:

  26:         public override void OnDisconnect(Controller controller) { }

  27:

  28:         public override void OnExit(Controller controller) { }

  29:

  30:         public override void OnFrame(Controller controller)

  31:         {

  32:             var frame = controller.Frame();

  33:             _now = frame.Timestamp;

  34:             _timeDifference = _now - _previous;

  35:

  36:             if (frame.Hands.IsEmpty) return;

  37:

  38:             _previous = frame.Timestamp;

  39:             if (_timeDifference < 1000) return;

  40:

  41:             // Run async

  42:             if (frame.Gestures().Count > 0)

  43:                 Task.Factory.StartNew(() => OnGestureMade(frame.Gestures()));

  44:             if (frame.Fingers.Count > 0)

  45:                 Task.Factory.StartNew(() => OnFingersRegistered(frame.Fingers));

  46:         }

  47:     }

  48: }

The listener is quite simple, public an event with the information captured by the LEAP every 1 second.

In the MainWindow of my WPF app, I have the following code. The only thing that must be taken into consideration, is that the best sensor initialization in the Loaded() event, and always with care for closing the View close the controller and the listener with the sensor.

   1: using System;

   2: using System.ComponentModel;

   3: using System.Diagnostics;

   4: using System.Runtime.CompilerServices;

   5: using System.Windows;

   6: using Leap;

   7: using LeapWpf01.Annotations;

   8:

   9: namespace LeapWpf01

  10: {

  11:     public partial class MainWindow : INotifyPropertyChanged

  12:     {

  13:         private string _gesturesText;

  14:         private Controller _controller;

  15:         private ElBrunoListener _listener;

  16:         private string _fingersText;

  17:

  18:         public MainWindow()

  19:         {

  20:             DataContext = this;

  21:             Loaded += MainWindow_Loaded;

  22:             Closing += MainWindow_Closing;

  23:             InitializeComponent();

  24:         }

  25:

  26:         void MainWindow_Closing(object sender, CancelEventArgs e)

  27:         {

  28:             _controller.RemoveListener(_listener);

  29:             _controller.Dispose();

  30:         }

  31:

  32:         void MainWindow_Loaded(object sender, RoutedEventArgs e)

  33:         {

  34:             _listener = new ElBrunoListener();

  35:             _controller = new Controller();

  36:             _controller.AddListener(_listener);

  37:             _listener.OnFingersRegistered += OnFingersRegistered;

  38:             _listener.OnGestureMade += OnGestureMade;

  39:         }

  40:

  41:         void OnGestureMade(GestureList gestures)

  42:         {

  43:             var gesturesData = string.Empty;

  44:             foreach (var gesture in gestures)

  45:             {

  46:                 gesturesData += gesture.Type + Environment.NewLine;

  47:             }

  48:             GesturesText = gesturesData;

  49:         }

  50:

  51:         void OnFingersRegistered(FingerList fingers)

  52:         {

  53:             FingersText = "Active Fingers:" + fingers.Count;

  54:         }

  55:     }

  56: }

Then, the functionality of the app is pretty straigh forward,

 

The sensor is OK, but in order to have something up and running, you have to work a lot. The SDK gives you raw information , so you have to work with this information to get cool results

Saludos @ Home

El Bruno

image image image Google

[# VS2012] There are many rumors about VS2012 and WP but less news than on the location of Atlantis

image

Buenas,

Disclaimer: When I wrote this post I was not at my 100% mental level. Thanks to @wasat I got more information and I still wait for some cool tools Open-mouthed smile

I do not understand very well that are passed by the head to our friends of MS with regard to development of Windows 8, Windows Phone and Visual Studio 2012 tools. VS11 Developer Preview and VS11 Beta versions, half who understood that the extensions might not exist to develop for WP but with a final version, they are not… scares me a little.

Once more have to be installed Side-By-Side VS2010 and VS2012 RC to be able to pull a few lines on WP… Worst thing is that neither seems to be much official information on dates of release, roadmap, etc. Except this thread of StackOverflow and a couple of articles, there is nothing of nothing…

Anger again… Angry smile

Saludos @ Home

El Bruno

image image image

[RESHARPER] HowTo: Dynamic add references based on the typed code

Buenas,

otro tip de los buenos de ReSharper, en este caso que nos ayuda a ahorrarnos los 5 clicks o 15 segundos necesarios para agregar una referencia en un proyecto. Supongamos el siguiente escenario:

  • Proyecto de biblioteca de clases llamado ClassLibrary1, con una clase llamada Class1.
  • Proyecto de biblioteca de clases llamado ClassLibrary2, con una clase llamada NewClass.

En la clase NewClass escribimos el siguiente código y esperamos la ayuda contextual de ReSharper sobre la línea con la declaración y la referencia a Class1. Como se puede ver en la imagen, además de las típicas propuestas de crear una variable local, un parámetro, etc; ahora también tenemos una opción que agrega una referencia al proyecto ClassLibrary1 y luego nos permite utilizar el tipo Class1.

image

 

Esto no solo aplica a las referencias entre los proyectos de una solución. Si por ejemplo, declaramos un tipo del modelo de objetos del cliente de Team Foundation Server 2010 para Visual Studio 2010, también podremos ver como nos propone agregar una referencia dinámicamente al tipo Microsoft.TeamFoundation.Client.

image

 

Aunque, cuidado que este segundo ejemplo tiene trampa > ReSharper no es lo suficientemente inteligente para conocer TODOS LOS ENSAMBLADOS, sino que infiere el tipo a referenciar ya que una de las referencias del proyecto actual tiene esa referencia, en el ejemplo anterior, la referencia a ClassLibrary1 desde ClassLibrary2, permite importar las referencias del primero hacia el segundo

image

 

Otro +1 para ReSharper Open-mouthed smile

 

Saludos @ Home

El Bruno (@elbruno en Twitter)