Question

I opened a solution file that was working fine and got this mysterious error

The 'CctSharedPackage' did not load correctly

This project was a Windows Azure 2.1 project that had no issues working last week, however between then and a reboot it would not successfully load in Visual Studio 2012 any longer. This occurred on a machine that does have Windows Azure SDK 2.1 installed (the project did work fine last week)

The error stated to check the c:\Users\{user}\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml file for more information.

In this file it stated "Could not find assembly Microsoft.Azure.Diagnostics ver 2.1".

Was it helpful?

Solution

Seeing as Windows Azure SDK 2.1 was already installed, i redownloaded the installer and went to run it to ask it to reinstall or repair the installation. Seeing as the install is the Web Platform Installer, it provided none of those options. At this point I decided that I must uninstall the SDK to be able to reinstall it from Add/Remove Programs.

When I went to Add/Remove Programs I saw that there were installations there for Windows Azure Libraries for .NET - v1.8 and Windows Azure Authoring Tools - v1.8. I removed both of these installations and then the project was able to load successfully.

OTHER TIPS

this seems to be a problem with the installer. Re-installing is an option, but you can fix it with a simple command line by registering your assemblies in the GAC.

C:\Program Files (x86)\Windows Azure Tools\Visual Studio 11.0>gacutil /i .\Microsoft.VisualStudio.WindowsAzure.Diagnostics.dll

I don't have the 1.8 SDK installed. I believe it was a windows update relating to .Net 3.5 which might have broken my installation. To Fix all I did was open up Explorer in Windows 8 and select the 'Uninstall or Change a program' option from the ribbon.

Search for Azure and when there was an option to 'repair' I repaired the program. FIXED

I ran into similar problem (The 'CctSharedPackage' did not load correctly). In my case starting Visual Studio with Run as administrator solved the issue.

I also encountered this prolem today, but for me luckily it was solved just by restarting Visual Studio 2012. Just try it at least once to be sure :-) !

I was having this same problem. Reinstalling SDKs didn't seem to be helping and reinstalling Visual Studio sounded too painful so I decided to figure out what was causing the error.

I used another instance of Visual Studio and attached it to debug the offending Visual Studio instance. I couldn't see where the exact error was happening, but I was able to see what library the exception occured in and could see the source code using .NET Reflector to get an idea of what it does.

On startup the Microsoft.Cct.CctSharedPackage library iterates through all the Azure SDKs to figure out which ones are installed on your computer.

I ended up writing a console application to emulate what the startup does and see if I could find what was wrong. All the classes are internal so I had to use reflection to access them.

On my computer it turned out to be the Azure SDK 1.6 that was messed up. The SDK was installed, but the TargetAzureLibraries property was coming back as null. I uninstalled that SDK and it corrected the problem.

Console app below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WindowWidth = 240;

            // The Microsft.Cct.AssemblyResolver does this:
            /*
        private IEnumerable<IAzureToolsVersionInfo> GetInstalledSDKsByProductVersionDesc(IServiceProvider serviceProvider) => 
            (from knownProduct in AzureToolsVersionInfoUtilities.GetAllProducts()
                where knownProduct.TargetAzureSDK.IsSDKInstalled() && knownProduct.TargetAzureLibraries.IsLibrariesInstalled()
                orderby knownProduct.ProductVersion descending
                select knownProduct)
            */
            // Duplicate this logic using reflection to find the SDK install that is broken.

            var asm = System.Reflection.Assembly.LoadFile("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Windows Azure Tools\\Microsoft.VisualStudio.WindowsAzure.Common.2.8.dll");
            var typ = asm.GetType("Microsoft.Cct.ProductVersionInfo.AzureToolsVersionInfoConstants");
            //Console.WriteLine(typ.ToString());
            var allMethods = typ.GetFields(BindingFlags.Static | BindingFlags.Public).Select(it => it.Name).ToArray();
            allMethods = allMethods.Where(it => it.StartsWith("WAT") && it.Length == 5).OrderBy(it => it).ToArray();
            foreach (string version in allMethods)
            {
                var fld = typ.GetField(version, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
                dynamic val = fld.GetValue(null);
                var azTypeInfo = asm.GetType("Microsoft.Cct.ProductVersionInfo.AzureToolsVersionInfo");
                bool isSdkInstalled = false;
                bool isLibrariesInstalled = false;
                Dictionary<string, string> sdkProperties = new Dictionary<string, string>();
                Dictionary<string, string> libProperties = new Dictionary<string, string>();

                // Get the SDK reference
                var targetAzureSDK = azTypeInfo.GetProperty("TargetAzureSDK").GetValue(val);
                Type targetAzureSDKProp = targetAzureSDK.GetType();
                var methodNames = targetAzureSDKProp.GetMethods().Select(it => it.Name).ToArray();
                var sdkIsInstalledMethod = targetAzureSDKProp.GetMethods().FirstOrDefault(it => it.Name == "IsSDKInstalled");
                isSdkInstalled = (bool)sdkIsInstalledMethod.Invoke(targetAzureSDK, null);
                var sdkProps = targetAzureSDKProp.GetProperties().ToArray();
                foreach (var prop in sdkProps)
                {
                    try
                    {
                        sdkProperties[prop.Name] = string.Concat(prop.GetValue(targetAzureSDK));
                    }
                    catch (Exception ex)
                    {
                        sdkProperties[prop.Name] = "Error:" + ex.Message;
                    }
                }

                if (isSdkInstalled)
                {
                    // Get the Azure libraries reference
                    var targetAzureLibraries = azTypeInfo.GetProperty("TargetAzureLibraries").GetValue(val);
                    Type targetAzureLibrariesProp = targetAzureLibraries.GetType();
                    var isInstalledMethod = targetAzureLibrariesProp.GetMethods().FirstOrDefault(it => it.Name == "IsLibrariesInstalled");
                    isLibrariesInstalled = (bool)isInstalledMethod.Invoke(targetAzureLibraries, null);
                    var props = targetAzureLibrariesProp.GetProperties().ToArray();
                    foreach (var prop in props)
                    {
                        try
                        {
                            libProperties[prop.Name] = string.Concat(prop.GetValue(targetAzureLibraries));
                        }
                        catch (Exception ex)
                        {
                            libProperties[prop.Name] = "Error:" + ex.Message;
                        }
                    }
                }
                // Output details of this SDK
                Console.WriteLine("{0}, {1}, {2}", version, isSdkInstalled, isLibrariesInstalled);
                Console.WriteLine("\tSDK");
                foreach (var kp in sdkProperties)
                {
                    Console.WriteLine("\t{0} {1}", kp.Key, kp.Value);
                }
                Console.WriteLine("\tLib");
                foreach (var kp in libProperties)
                {
                    Console.WriteLine("\t{0} {1}", kp.Key, kp.Value);
                }
            }
        }
    }
}

Uninstalled all Windows Azure entries ending with October 2012 via control panel. After reopening my solution I got a dialog to convert the project target (screenshot).

Azure upgrade

I second the turn it off then on again option. Got this error on loading a project after a week away. Rebooted and it went away. So try that at least once.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top