【问题标题】:Windows Azure project errors The CctSharedPackage did not load correctlyWindows Azure 项目错误 CctSharedPackage 未正确加载
【发布时间】:2023-03-25 05:06:01
【问题描述】:

我打开了一个运行良好的解决方案文件并得到了这个神秘的错误

“CctSharedPackage”未正确加载

这个项目是一个 Windows Azure 2.1 项目,上周运行没有问题,但是从那时到重新启动,它无法再在 Visual Studio 2012 中成功加载。这发生在安装了 Windows Azure SDK 2.1 的机器上(该项目上周运行良好)

检查 c:\Users\{user}\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml 文件以获取更多信息。

在此文件中,它声明“找不到 Microsoft.Azure.Diagnostics 2.1 版程序集”。

【问题讨论】:

  • 您可以通过在 GAC 中注册程序集来解决此问题...更多信息请参阅下面的答案。

标签: visual-studio-2012 azure projects-and-solutions


【解决方案1】:

看到已经安装了 Windows Azure SDK 2.1,我重新下载了安装程序并运行它要求它重新安装或修复安装。看到安装是 Web 平台安装程序,它没有提供这些选项。此时我决定必须卸载 SDK 才能从添加/删除程序重新安装它。

当我转到添加/删除程序时,我看到那里安装了适用于 .NET 的 Windows Azure 库 - v1.8 和 Windows Azure 创作工具 - v1.8。我删除了这两个安装,然后项目能够成功加载。

【讨论】:

  • 我在同一条船上,但我所做的是选择 Azure 2.1,选择修复选项,修复完成后一切正常。
  • 此解决方案也适用于 Visual Studio 2012 Update 4。修复完成后,Azure 2.1 一切正常。
  • 我将 2012 年 6 月和 2012 年 10 月的版本与 2.1 一起安装。我按照建议删除了两个旧版本,现在一切正常。即使没有对 2.1 版本进行任何修复操作。
  • 我遇到了同样的问题,在我的情况下,SDK 2.0 和 2.2 都安装了。通过转到添加/删除程序,按“Azure”过滤并修复所有具有此选项的项目来解决。
  • 我今天在 Windows 更新后也遇到了这个问题。两次重启,问题就消失了。
【解决方案2】:

这似乎是安装程序的问题。重新安装是一种选择,但您可以通过在 GAC 中注册您的程序集,使用简单的命令行来修复它。

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

【讨论】:

  • 比重新安装简单得多的解决方案
【解决方案3】:

我没有安装 1.8 SDK。我相信这是与 .Net 3.5 相关的 Windows 更新,它可能破坏了我的安装。为了解决所有问题,我在 Windows 8 中打开资源管理器并从功能区中选择“卸载或更改程序”选项。

搜索 Azure,当有“修复”选项时,我修复了程序。固定

【讨论】:

  • 这对我有用,是此页面上破坏性最小的建议。除了,我在 Windows 8.1 的功能区中找不到卸载/更改选项。我是从老式的控制面板做的。
  • 这个。这也是此 MSDN 博客文章 blogs.msdn.com/b/rob/archive/2014/02/12/… 中的一个流行修复。
【解决方案4】:

我遇到了类似的问题(“CctSharedPackage”没有正确加载)。在我的情况下,以管理员身份运行启动 Visual Studio 解决了这个问题。

【讨论】:

  • 我将我的 Visual Studio 设置为始终以管理员身份启动,方法是使用 VSCommands vscommands.squaredinfinity.com/home 和“始终以提升的权限启动 Visual Studio”选项
【解决方案5】:

我今天也遇到了这个问题,但幸运的是,只需重新启动 Visual Studio 2012 即可解决。至少尝试一次即可确定 :-)!

【讨论】:

    【解决方案6】:

    我遇到了同样的问题。重新安装 SDK 似乎没有帮助,重新安装 Visual Studio 听起来太痛苦了,所以我决定找出导致错误的原因。

    我使用了另一个 Visual Studio 实例并附加它来调试有问题的 Visual Studio 实例。我看不到确切的错误发生在哪里,但我能够看到异常发生在哪个库中,并且可以使用 .NET Reflector 查看源代码以了解它的作用。

    在启动时,Microsoft.Cct.CctSharedPackage 库会遍历所有 Azure SDK,以确定您的计算机上安装了哪些。

    我最终编写了一个控制台应用程序来模拟启动的操作,看看我是否能找出问题所在。所有的类都是内部的,所以我不得不使用反射来访问它们。

    在我的电脑上,原来是 Azure SDK 1.6 搞砸了。 SDK 已安装,但 TargetAzureLibraries 属性返回为 null。我卸载了那个 SDK,它解决了这个问题。

    控制台应用如下:

    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);
                    }
                }
            }
        }
    }
    

    【讨论】:

      【解决方案7】:

      通过控制面板卸载了 2012 年 10 月结束的所有 Windows Azure 条目。重新打开我的解决方案后,我得到一个对话框来转换项目目标(屏幕截图)。

      【讨论】:

      • 请注意,升级主要版本可能会导致重大更改
      • @Stefan 你怎么看 - 你的评论不准确..?
      • 我不确定我明白你在说什么,Renato,你能解释一下吗?
      • 您在谈论“主要版本”和“重大更改” - 我认为我的示例中的事件很清楚 - 从(2012 年 10 月迁移到 v2.1)。那么迁移时的“重大变化”是什么?向导不应该小心并在必要时发出警告吗?
      • 2012 年 10 月版本为 v1.8 - 进行此类升级时,需要参考升级文档(可在此处获取 -> windowsazure.com/en-us/downloads/archive-net-downloads
      【解决方案8】:

      我支持将其关闭然后再次打开选项。一周后加载项目时出现此错误。重新启动它就消失了。所以至少尝试一次。

      【讨论】:

        猜你喜欢
        • 2015-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-14
        • 1970-01-01
        相关资源
        最近更新 更多