Thursday, May 16

Hyper-V: Build your own local lab (with access from host to guest)

I’m really not a “networky” guy at all; but with the skilled help of a college I actually managed to get a locally hosted Hyper-V environment established on my DEV laptop with a WIFI card. So with my sincere thanks to Patrick Schneider, I will be documenting how to setup this stuff. Indeed also for my own sake!

1) Go to Virtual Hyper V Manager (Virtual Switch Manager…)

image

2) Create an internal switch

 image

3 Go to Network Settings on the host computer

image

4) Enter these values (still on the host laptop) on the newly created virtual internal network switch (step 2)

image

5) You are done with the host for now

6) Start the LAB-AD and connect using Hyper-V connection

7) Open the Network Settings on the LAB-AD

image

8) Set these values

image

9) Open LAB-SYNC

10) Set these values

image

11) You are done

12) Open a remote desktop (run mstsc) and enter 10.1.0.100 (You should reach LAB-AD)

14) Open a remote desktop (run mstsc) and enter 10.1.0.110 (You should reach LAB-SYNC)

Voila!

Thursday, April 18

Azure AD and System.IdentityModel.Tokens.ValidatingIssuerNameRegistry not found?

It should be so easy, but nothing really is when it comes down to reality!
Following the how-to from Microsoft (http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx), you might run into a problem with your application not being able to find the assembly holding System.IdentityModel.Tokens.ValidatingIssuerNameRegistry? It will simply throw an error and show a stack trace.

It turns out there is a screw up with the version (4.5.1) included in WIF* and the sample. So to remedy this problem – uninstall the package using the nuGet console like this

UnInstall-Package System.IdentityModel.Tokens.ValidatingIssuerNameRegistry

and install the previous version 4.5.0 like this:

Install-Package System.IdentityModel.Tokens.ValidatingIssuerNameRegistry –Version 4.5.0

This will actually make your application work ;-)

* Windows Identify Foundation

Monday, February 18

GAC: Force an assembly to un-install

Sometimes when developing assemblies that needs to reside in GAC to work (thanks Microsoft!); it can prove very difficult to uninstall an assembly from this bucket of dlls.

I today found a good tip on how to force that operation.

  1. Open RegEdit
  2. Go to the below location.
  3. Delete the entries you wish to remove from here
  4. You can now delete them from the GAC (in the file system)

image

Link: http://abhi.dcmembers.com/blog/2009/04/17/forcefully-delete-an-assembly-from-gac/

Thursday, February 14

Regex: matching some words but not others

Man, I hate with a full heart the inventor of Regex, even though I’ll admit that it really can come in handy at times. The main thing with Regex is that “nobody” that are just somewhat sane can maintain these “cyrilic” scripts and strings that Regex ends up in. It’s just gibberish to say the least!  Some would even argue that it looks like a quote from Captain Haddock in Tintin!

So – how does this beast look?

input: “here we WE go again” (the ‘”’ is not part of the input)

Regex Expression Result
\w

Explanation: all alphanumeric chars
h
e
r
e
w
e
W
E
g
o
a
g
a
i
b
\b\w+\b

Explanation: all alphanumeric chars that combines into a word
(1 <= char count < infinity)
here
we
WE
go
again
\b\w{1,3}\b

Explanation: all alphanumeric words
(1 <= char count <=3)
we
WE
go
\b\w{4,}\b

Explanation: all alphanumeric words
(4 <= char count < infinity)
here
again
\b\w{2}\b

Explanation: all alphanumeric words
(2 = char count)
we
WE
go
\b(?!\bwe\b)(\w{2})\b

Explanation: all alphanumeric words but NOT ‘we’
(2 = char count)
go
WE
\b(?!\bgo\b)(\w{2})\b

Explanation: all alphanumeric words but NOT ‘go’
(2 = char count)
we
WE
(?i)\b(?!\bwe\b)(\w{2})\b

Explanation: all alphanumeric words but NOT ‘we’
(2 = char count). Ignore case
go
(?i)\b(?!\bwe\b)(?!\bgo\b)(\w{2})\b

Explanation: all alphanumeric words but NOT ‘we’ OR ‘go’
(2 = char count). Ignore case
(nothing)

It still looks like gibberish to me!

Wednesday, January 30

WPF MenuItem programmatically

I seriously don’t know what they had been smoking in Redmond when they invented the URI scheme for WPF. It’s really far from intuitive nor understandable, so if you have set out to create e.g. a ContextMenu programmatically (code over Markup XAML); you are in for a surprise!

Building an editor that required a dynamic tabcontrol (you can add/delete the tabs during runtime); I had to enable a contextmenu associated to these new runtime defined tab items. But, creating these menuitems in code (C#) is not intuitive. So, if you don’t want to spend 1½ hour hunting how to do this, here is how:

        private void NewTab_MouseUp(object sender, MouseButtonEventArgs e)
{
MenuItem editMnu = new MenuItem();
editMnu.Click += editMnu_Click;
editMnu.Header =
"edit";
editMnu.Icon =
new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Images/edit.png", UriKind.Absolute))};

MenuItem delMnu = new MenuItem();
delMnu.Click += delMnu_Click;
delMnu.Header =
"delete";
delMnu.Icon =
new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Images/cancel.png", UriKind.Absolute)) };

ContextMenu cmnu = new ContextMenu();
cmnu.Items.Add(editMnu);
cmnu.Items.Add(delMnu);

(rest omitted)


 


Note the format of the Uri-scheme “pack://applica…..”.! That guy actually points to a location within the application inside the Images folder (see below).


image


Ultimately, you end up with a new tab with this Contextmenu:


image


Who should have known…

Monday, January 28

Microsoft.Expression.Interaction.dll – where is it?

For the life of me, I could not find the interaction assembly from Microsoft. And “Googling” the matter only reveals that I was most certainly not the only one with that problem! I learned, that it is included as part of the Expression Blend SDK for Silverlight 4.

image

And can be found here (on a Win8 machine):
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries


image

URL friendlyUrls not working?

Attempting to make use of the Microsoft.FriendlyUrls Nuget package to solve a routing problem I was installing this into my application. According to all documentation you simply enable this by typing:

  public class Global : System.Web.HttpApplication
{

protected void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(
RouteTable.Routes);
}

The thing is though, that it does not work! It complains it does not know the RouteConfig class.


To make this work, you need to install an additional package (note the prerelease selection)


image