Update-Database fails in Package Manager Console on Windows 10 Insider Preview with ambiguous type error


This post is about providing a workaround for this problem until Microsoft provide us with a proper fix.

This problem has been reported here:

There seem to be two types that fail due to ambiguity:

  • Microsoft.VisualStudio.Shell.Package
  • NuGet.VisualStudio.IVsPackageInstallerServices

Yet if you have other failing types in your scenario, understand this post and apply the same logic to your specific case.

Microsoft.VisualStudio.Shell.Package

This workaround fixes the following error:

Type name 'Microsoft.VisualStudio.Shell.Package' is ambiguous, it could be 'Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or 'Microsoft.VisualStudio.Shell.Package, 
Microsoft.VisualStudio.Shell.10.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

To fix this, do the following:

  1. Open Windows PowerShell ISE in admin mode (right click and Run as Administrator)
  2. Open the following file:
    • C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\ZPM4HZQB.YOS\Modules\NuGet\Profile.ps1
  3. Go to line number 126 (Ctrl+G and enter the number)
  4. Find this line:
    • $service = [Microsoft.VisualStudio.Shell.Package]::GetGlobalService($ServiceType)
  5. Replace it with these lines:
    • $accel = [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
       $accel::add(“specificShell”,”Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”)
       $service = [specificShell]::GetGlobalService($ServiceType)
  6. If your Visual Studio is open, you will need to close it and re-open it, as it caches a copy of this script.

NuGet.VisualStudio.IVsPackageInstallerServices

This is a similar fix to the above, but for this error:

Type name 'NuGet.VisualStudio.IVsPackageInstallerServices' is ambiguous, it could be 'NuGet.VisualStudio.IVsPackageInstallerServices, JetBrains.Platform.VisualStudio.SinceVs11, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325' or 
'NuGet.VisualStudio.IVsPackageInstallerServices, JetBrains.PsiFeatures.VisualStudio.SinceVs11, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325'.

To fix this, do the following:

  1. Open Windows PowerShell ISE in admin mode (right click and Run as Administrator)
  2. Open the following file (replace {NuGetPackagesFolder} with the location of your packages folder in your solution:
    • {NuGetPackagesFolder}\EntityFramework.6.1.3\tools\EntityFramework.psm1
  3. Go to line number 1004 (Ctrl+G and enter the number)
  4. Find this line:
    • $packageInstallerServices = $componentModel.GetService([NuGet.VisualStudio.IVsPackageInstallerServices])
  5. Replace it with these lines:
    • $accel = [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
       $accel::add(“NuGetInstallerServices”,”NuGet.VisualStudio.IVsPackageInstallerServices, JetBrains.Platform.VisualStudio.SinceVs11, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325”)
       $packageInstallerServices = $componentModel.GetService([NuGetInstallerServices])
  6. As above, if your Visual Studio is open, you will need to close it and re-open it, as it caches a copy of this script.

The Logic

All I am doing here is quite simple, I am creating a type alias that points to a specific assembly instance, and using that for reference, rather than the version that would resolve into multiple instances.

A Few Notes

The workaround above, particularly the second one, is temporary, and will fail again if you refresh your NuGet package cache before MS come up with a fix for this problem.

Also, since all machines have different configurations, your specific assemblies might be different.  So just replace them above accordingly… you are all devs after all ;)

Of course, to fix, simply re-apply the patch above.

This problem is still present as of Windows 10 Insider Preview Build 14257.rs1_release.160131-1800

Advertisements

Visual Studio 2012/2013 Page Inspector fails with “Object reference not set to an instance of an object”


I’ve had this problem for as long as I can recall.  My page inspector in Visual Studio 2012 never worked… which normally would have been ok, since I could always do the old-school edit+save+refresh routine… but when you know that the feature exists, it is a bugger that it doesn’t work.

I tried everything, from disabling all my extensions and add-ons, to hooking up a debugger to my devenv process… to the obvious google-and-bing-fu manic searches… but got nothing.

If you check your ActivityLog.xml, you will see that Page Inspector is blowing up with a NullReferenceException… no surprise there.

After installing VS2013 I hoped that all of this would go away, but I got the same error.

Page Inspector fails with Object reference not found
Page Inspector fails with Object reference not found

Finally, I had the great brain wave of setting Internet Explorer as my default browser and restarting Visual Studio (I’m a chrome user).

…and voilà… page inspector finally works :(

One would think that by this time, this whole thing about being wired-in to Internet Explorer was a thing of the past… clearly it is not.

I’ve filed a bug report accordingly on Microsoft Connect.

DM2S63MFEY9G

SetSite failed for package [CctSharedPackage]


I’ve seen this exception way too many times in Visual Studio 11 and 12… turns out that it is an issue with Azure SDK 2.2 – and my google-fu skills failed to find a solution online.

Yet… if you look into your C:\Users\[username]\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml file, you’ll find errors on the lines of:

Could not load file or assembly ‘Microsoft.VisualStudio.WindowsAzure.Diagnostics, Version=2.2.0.0…

The fix turns out to be quite simple, once you see that error.  This just means that the assembly cannot be found… so hey, just add it to your GAC like so:

Add assembly to GAC
Add assembly to GAC

Voila… problems solved.

 

Show more tiles on your Windows 8 and 8.1 start screen


Ok, so I’m slowly getting used to the Windows 8+ tiles mode for the start screen, and I’m admittedly preferring it to the old start menu, or the full blow ‘all apps’ view that’s available as of Windows 8.1.

But wouldn’t it be nice if we could make the tiles smaller?

This is actually an option, but quite a hidden option.

This is my tiles view before:

Windows tiles default view
Windows tiles default view

And here is what they look like after:

Smaller windows tiles
Smaller windows tiles

How do I do it? ..you may ask

Simple, just:

  • Open your charms (put your mouse in one of the left corners, or slide your finger from the right edge of the screen, inward).
  • Select Settings
  • Select Tiles
  • Select Show More Tiles
Show more tiles
Show more tiles

Note: This only applies if you select ‘settings’ whilst in ‘Tiles View’ (i.e. not in desktop mode)

I hope this helps someone :)

Windows 8 thoughts after a day at BUILD 2011


In this post, my fellow friend, colleague, C# Disciple and MVP Marlon Grech gives a good overview of his impressions of Windows 8 and how it will affect the future of computing.

Hop over to the link to see what he thinks -> ‘the link :)

Demystifying WPF XML namespaces


WPF XML namespaces are those fancy little cryptic strings at the top of every WPF application that you use (generally prefixed with xmlns=”..”, meaning that they are the ‘default’ namespace [i.e. no prefix required]).

But what do they mean?

Simply put, they are ‘short cuts’ to import a whole plethora of .NET WPF assemblies and make their contents available for use in your XAML file.

The most commonly used namespace is http://schemas.microsoft.com/winfx/2006/xaml/presentation, and it imports the following .NET namespaces

  • System.Windows
  • System.Windows.Automation
  • System.Windows.Controls
  • System.Windows.Controls.Primitives
  • System.Windows.Data
  • System.Windows.Documents
  • System.Windows.Forms.Integration
  • System.Windows.Ink
  • System.Windows.Input
  • System.Windows.Media
  • System.Windows.Media.Animation
  • System.Windows.Media.Effects
  • System.Windows.Media.Imaging
  • System.Windows.Media.Media3D
  • System.Windows.Media.TextFormatting
  • System.Windows.Navigation
  • System.Windows.Shapes
  • System.Windows.Shell

As you might (or might not) know, there are other XML namespaces that you can use, each represents a particular version of WPF as follows (to date):

Note that these are all mapped to the same WPF assemblies, though they implicitly define which version of WPF you are targeting.

Also, a note about winfx vs netfx:  winfx was the original name that was used to refer to the W*F technologies (WCF,WPF,WF)… this was later ditched by Microsoft.

Where is XamlPad? How can I download it?


If any of you are like me, you may have read some book, or some blog, that refers to a seemingly obscure little utility called XamlPad.

I read that this was included with the .NET Framework 3.0 SDK… so, I searched high and low… but XamlPad continued to elude me.

Further research showed that XamlPad is no more, surprisingly (or not*) due to Microsoft having a lack of resources.

There are though a few alternatives running around in the wild:

  • XamlPadX – created by a WPF team member (Lester Lobo) and full of bells and whistles ->fetch
  • XAML Cruncher – a ClickOnce application (neat), created by Charles Petzold (haven’t heard of him? Shame on you!) ->fetch
  • Kaxaml – Robby Ingebretsen’s offering (ex WPF team member) ->fetch

* well, I say ‘or not’ here since even if Microsoft do have LOTS of developers, they are also pretty busy nowadays, so I am not surprised that a teeny tool like this would be pushed aside, considering that there are comparable maintained tools out on the market already.