2 Comments

Here I would like to present a small recipe, that will let you enable monitoring of WCF server-side calls with Microsoft’s ApplicationInsights service. It might help you in analytics of:

  • what services are used mosts
  • what hours users are active
  • what are the response times
  • what is called far too often and needs optimization
  • and probably most important thing - what crashed, why, when with the callstack!

It’s pretty straightforward and I split it into two parts.
First part - tasks are required to be done on the Azure side. For the foremost – you will need an Azure Account and an active subscription. I am assuming you already got one. Details are out of the subject for this tutorial. Even though Azure is a paid service, an ApplicationInsights till first million of actions is free as I remember correctly.
Second part – how to update the server-side of an application to utilize the Application Insights service. It focuses on proper packages installation via NuGet and the configuration.


Let’s go then. Do it on Azure:

  1. Login into Azure Portal.
  2. Click on “Create a resource” and input “Application Insights” in a search field. Then click “Create” button.

    Azure Create AppInsights resource


  3. Select an “ASP.NET web application” and complete the process.
  4. After few seconds, new service will be created, navigate to it.
  5. What is really required to store/remember is called “Instrumentation key”. Obtain it from the “Properties” section or via “Essentials” part of the “Overview” section as shown below.

    Azure AppInsights Overview


  6. We are done here.


Now, it’s time to update the ASP.NET WCF application, to post metrics and call to Azure appropriately.

  1. Open your solution in Visual Studio 2015 Community (or newer).
  2. Navigate to “Tools –> NuGet Package Manager –> Package Manager Settings –> Package Source” as on picture below.
  3. Add new source for AppInsights SDK (open-sourced and hosted on GitHub).

    NuGet Sources

    Name it anyhow you like, and use “https://www.myget.org/F/applicationinsights-sdk-labs” as source URL.

  4. Install the package: “Microsoft.ApplicationInsights.Wcf” (Include prerelease should be checked). It should also download all other packages it depends on.

    AppInsights Packages

  5. Now, inside the Globa.asax file, update the “Application_Start” method. Enable the monitoring of the application by placing the “Instrumentation Key”. The value we got earlied from Azure Portal, when the cloud service itself was created.

    TelemetryConfiguration.Active.InstrumentationKey = "my-instrumentation-key";

    AppInsights Instrumentation Key


  6. All the other necessary configutaion could be tweaked via code or ApplicationInsights.configfile, that was added to the project during packages installation. At this time, we don’t need to modify it anyhow.
  7. So we are done. Now the new version of the application is ready to be deployed. Once this is finished, statistics will be uploaded and visible through poral almost in real time.

    If you can visit the portal again after some time, instead of being empty, it should display content as follows:

    Azure AppInsights working

That was it!

0 Comments

After recent upgrade to Windows 10 Fall Creators Update my wake-on-lan feature of the desktop PC stopped to work. It was not very surprising, as most of the settings during such a big OS update usually goes to defaults.

Here are two simple steps to restore it. Only two - as I already had it enabled in my UEFI BIOS on the motherboard and also installed drivers for my build-in Intel network card 82579V. However I am not sure, if this driver update is required at all and the default Microsoft’s one will suffice. Anyway:


  1. Launch Device Manager and navigate to Network Adapters. Then on Power Management tab of the network card enable all “wake up” options. Also on Advanced tab enable Magic Packet.

    Enabling Magic Packet (Win PL)


  2. Navigate to Control Panel, then go into Power Options and on the left side click Choose what the power buttons do. After that go into Change settings that are currently unavailable. Finally uncheck (disable) fast-startup mode to let the PC respect the network device power settings (set in previous step).

    Disabling fast-startup (Win PL)


That’s all what is needed!

0 Comments

And also preserving the machine’s role in the company!


Recently I discovered that on my build server resides Visual Studio 2010 with SP1. It occupies tremendous amount of space and at the first glance it was totally unnecessary to be there at all. So I had this brilliant though and immediately went to Control Panel and hit Uninstall. Which of course failed miserably after 20 minutes of processing. Then destroyed the hard drive even more with finalization that rolled back the whole procedure…

It failed due to lack of the original .msi file, the Visual Studio 2010 Premium was installed from. Uninstaller asked me to point the location, but I am not in a possession of the DVD nor ISO anymore. Pity, because it could have saved me a lot of stress and time then. And yes, I had been warned (and even agree to take the risk) that it could leave the whole installation in an undefined state, where IDE won’t work and SP1 can’t be applied again.

My problem was not the IDE at all, but all the builds I failed to compile from now on. The message looked like this:

C:\TC.build\z-2022\Project.Dto\Project.Dto.csproj(222, 3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Portable\v4.0\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

And fixing it started to be mission critical.


Fast forwarding to the day after.

Now, let me proudly present the solution:

  1. Download the Visual Studio 2010 uninstaller from here (cached also by me here).
  2. Open command prompt and type the command:
    ./VS2010_Uninstall-RTM.ENU.exe /full
  3. Hit enter and grab a coffee as it will take some time.
  4. Then download the Portable Library Tools from here.
  5. Type the command:
    ./PortableLibraryTools.exe /buildmachine
  6. Hit enter and wait few seconds to restore everything to normal.
    Without the switch it won’t install anything until it finds VS 2010 SP1 first!
  7. Optionally, if .NET Framework seems to be dead too it might be useful to also install .NET Framework Developer Pack 4.6.2.


All green again!

0 Comments

By default any calls done by Qt over HTTPS will fail. This is because the OpenSSL it relies on is not included into the distribution that was installed. All you have to do, to make it work, is to download OpenSSL 1.0.xxx library for Windows from here and install to any folder (for example: “C:\OpenSSL”). The tiny 3MB package is enough. Then copy the libeay32.dll and libssl32.dll into developed applications folder (the output one) and it will be automatically picked up during startup.

There is no need to mess anything with Qt at all (and for sure no need to rebuild Qt framework!).

It was also described on StackOverflow, too.

0 Comments


Latest version of QtCreator out of the box installs only Qt 5.0+. That’s rather obvious, but what if someone wants to play a bit with previous edition? Yeap v4.8, the one that is almost 4 years old! It is still doable and I will shortly show the way. Move to TL;DR if you are not interested in the background story.


You could ask why I wanted to do that in the first place, so here is the reason. I am still using a BlackBerry smartphone with BB10 OS onboard. And it’s much easier to develop (and test) a “meaty part” for a native app using the desktop edition of Qt in QtCreator and then only bind it with the UI using Momentics IDE than write everything there and deploy all the time on the device. This is much slower and tiring process, especially when the BB10 device emulator doesn’t work on Windows 10 with Hyper-V enabled…

Let me stop you here, before you start complaining about it. Although the BB10 platform itself is dead and abandoned, the same code can be used to develop Android apps (and of course UWP etc…), so not everything seems to be the waste of time. Download the NDK using Android Studio, use the MaintenanceTool.exe (from Qt installation folder) to add required architecture crosscompilers support and configure the paths, kits and deployment targets in QtCreator with this short guide.

Really, after all you will be much happier person, that Qt is the framework that binds all platforms together.


TL;DR

So how to add Qt 4.8.6 support?

1. First and foremost – Qt installation is required! You can obtain the free version for open-source projects from here. Select the options that suits best and simply install it. I used “C:\Qt” as destination path.

2. From Qt archives download the Qt 4.8.6 installer. I am not going to install VS2008 nor VS2010 on my machines anymore, so I went for MinGW-based version. I recommend using “C:\Qt\4.8.6” as the destination path, as it will be next to 5.10.0 version and will also simplify further configuration.

3. Matching MinGW compiler can be downloaded from here (ended at location: “C:\mingw32”)

4. Launch QtCreator and open “Tools –> Options”. Now we need to define locations for all the compilers, debuggers etc.

5.  Add new Qt Version. Use the ‘Add…’ button on the right and navigate for qmake.exe in 4.8.6 installation folder.

qt_4.8.6_qmake

6. On “Compilers” tab add new MinGW C compiler (gcc.exe).

c_compiler

7. Then add MinGW C++ compiler (g++.exe).

cpp_compiler

8. On “Debuggers” tab add appropriate GDB from MinGW folder.

gdb

9. Finally on “Kits” tab bind all the tools added in steps above.

mingw_qt_4.8.6_kit

10. Voilà. Now the newly created kit can be using to build future projects.


Supplement

It might happen, that the application won’t start. It’s mostly because there are some DLLs the output executable depends on (like: QtCore4.dll, QtNetwork4.dll, libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll or their debug editions). The easiest way is to copy them from Qt 4.8.6 installation directory into the debug-build folder (i.e.: <project>/../build-<kit>-<platform>/debug) manually, setup it up as a post-build step or make the DLLs generally visible by adding Qt 4.8.6/bin folder into PATH environment variable.