Windows 10… N – don’t use it for app development.

At least, if the app in question uses speech. Background is that I routinely use Azure VMs for development… so let’s extend that to writing apps. The ready-made VMs that also include Visual Studio are the “N” variants. So I used them, as usual. However, I wasted a number of hours failing to get to the bottom of this error when executing a pretty standard block of text-to-speech code (at the time I was not questioning whether “N” was OK to use):


Class not registered

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.
ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.
HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
 at HW.MainPage.d__1.MoveNext()} System.Runtime.InteropServices.COMException

I spent a lot of time after that trying to debug, googling up the wrong tree, reinstalling various releases of Visual Studio, all with the same, bad, result. In fact I should have just gone to bed, because as ever a tiny light bulb came on when I thought about… N.

So this morning I googled issues around Visual Studio and Windows N 10, and almost immediately found this:


So I tried the media feature pack, got a message that “does not apply to this installation” or somesuch. Yes I could have persevered, but decided to trash the N instance, and create a non-N instance, and manually install Visual Studio, and this sample. And then it was all fine.


And I thought there might be some issue with trying to do speech on a VM, but that was all fine, and came loud and clear through my speakers on my host PC. QED.



Visual Studio (“full fat”): Formatting, Options and Settings

I always struggle to remember where I find this stuff, so… (Gist)


.Net: simplest WCF service and client

In VS2015, I wanted to create the very simplest possible WCF service, and a client, in the form of a console app, to prove it works.

In VS, use the WCF template to create a WCF service library. As the template is a Hello World, I choose to call it HelloAcmeService (I don’t know why I’m randomly picking fictitious brands):

That creates an interface file, and a class file, which contain more than I want, so we strip those back to a minimum, and do some renaming.








…removing the stuff I don’t want, and some renaming:






After an OK build let’s make sure we can reference it from the browser, by pressing Start in VS , and then clicking on the BaseAddress hyperlink  in the app.config (or just typing it in):


Now we could plug the WSDL into SoapUI and get a richer client experience (if those words mean nothing, that can be for another tutorial). For now, we’ll just create a console app to use the service.

Stop the service running in VS, so you can go back to editing. Create a console app under the solution (please note – there is in fact a compile error later using this name for reasons I am not going into here, and I won’t redo the screenshots – please call the console app HelloServiceAClient – note the ‘A’):


That gives you this new content in the Solution Explorer:


You now need to add a Service Reference to use the service from this client. Right click on References/Add Service Reference…, and in the dialogue, click Discover:


Click OK, and Solution Explorer now looks like this:


Now in Program.cs, add the text highlighted to access the service and use the GetData() method from the service:


The last action before testing it is to right-click on HelloServiceAClient and select Set as Startup Project.


Now press the Play button in VS, and you get this exciting output:


That’s it.


Visual Studio… Code Snippets: no snippets manager?

.., no problem:

Keeping things simple, this is a basic snippet, that can act as a template. It has no parameters:


You will see that the Title and the ShortCut, and the filename, are all [MyTestMethodEmpty]. That helps with cataloguing and maintenance, I find.

So that is sitting on the file system in some scratch location, and we want to use it in Visual Studio.

These are the steps:

In Visual Studio, import the snippet you created earlier using any-old text editor (note that even though I intend to use this in C#, I have left the language at the default of Basic):


Browse to the location where you created/saved your snippet, and click [Open] ([Open] not shown in the screenshot):


The next dialog carries forward the named snippet, and suggests a location: this might be a default, or it might just be remembering my previous choice. I don’t care how it decided, this is fine for my purposes:


We then click [Finish]/[OK] (not shown here), and we return to the IDE.

There are 2 things to check: a) Does Visual Studio find the snippet, and b) where has it stored it?

a) Does Visual Studio find the snippet

In the IDE, I start to type [myt], and it finds the shortcut:


I then press tab twice… and it brings up the boilerplate that is clearly from the snippet I created (the squiggles are because I did the editing in a non-Test class). So this is clearly working:


b) where has it stored it?

I just don’t trust Windows Search (and that continues into Windows 10), so I use PowerShell to look for the wild card. Although it’s not efficient, on an SSD it goes pretty quickly. And this screenshot confirms on the file system what we asked for in the IDE, in that we created the file c:\temp, and Visual Studio must have followed the instruction to put in the [My Code Snippets folder].


gci -Path c:\ -Filter *empty*.snippet -Recurse -File -ErrorAction SilentlyContinue


As this are all pretty small, it is valid to take the whole content of the Code Snippets parent folder, and back that up – 25 files looks a bit suspiciously small, so maybe validate that before putting faith in the backup, but you get my point regarding size:


Blue below represents the things you would change in a template without parameters:

<?xml version=”1.0″ encoding=”utf-8″?>
<CodeSnippets xmlns=””&gt;
<CodeSnippet Format=”1.0.0″>
<SnippetTypes />
<Keywords />
<References />
<Imports />
<Declarations />
<Code Language=”csharp” Kind=”” Delimiter=”$”><![CDATA[[TestMethod]
public void TestMethod() {

Visual Studio: code snippets

As at work we might stop using ReSharper, I’ll assume that and come back to how you do Code Snippets, Visual Studio-style.

There’s this from MSDN which shows you how to create one.

This is how you can use it of course: you start to type letters and after some pre-defined pause it assumes you want to see the snippet library, in this case for all snippets starting with [p]:


Where has this come from?



Now interesting here is that e.g. the [propa] and [propdp] snippets are not in that list, so presumably it at least aggregates from a few different sources under the [C:\Program Files (x86)\Microsoft Visual Studio 14.0] area. So if I do try to find e.g. propdp,


, which expands to this promising code:VSSnippets04

I need to know the location and extension of a snippet, so from the Manager, I can get the location, giving this:


Notice that [Snippets] is below [VC#], rather than the other way round, which seems a bit mad to me. Regardless,I now know where to look for the propdp snippet:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\NetFX30



So that too is under the VC# umbrella, so maybe it is just grouping the C# bits together.

More MSDN [List of common C# snippets (.e.g. for properties)] [Create a New Snippet with Replacements] [Distribute Code Snippets]

Now my pet rant on C# code snippets vs ReSharper was the fact that you can’t do any on-the-fly substitution (see my YouTube elsewhere on what I mean by that) on macro variables. Fine, with a few extra keystrokes, you can achieve the necessary with the standard snippet [propfull]:

PropFull01 PropFull02

and in simple uses, this is probably enough (propg):


Might be helpful to show what underpins the fuller one, propfull:



Visual Studio: diagnostics

I am a fan of the debugger in Visual Studio. For a number of years now, I have seen the Intellitrace window appear more as an irritant… because I knew nothing about it. So today I took the trouble to watch the VS-embedded video on this. And it sounds promising, particularly the ability to run Intellitrace on a machine that does not have VS, and to collect the data for subsequent analysis on a machine that does.

The diagnostics section of the MSDN blog:

Channel 9 Visual Studio videos, including the Intellitrace one.