Visual studio 2012 Windows Azure项目错误CctSharedPackage未正确加载
我打开了一个工作正常的解决方案文件,发现了这个神秘的错误 “CctSharedPackage”未正确加载 该项目是一个Windows Azure 2.1项目,上周工作时没有问题,但是从那时起到重新启动之间,它将无法再在Visual Studio 2012中成功加载。这发生在安装了Windows Azure SDK 2.1的计算机上(该项目上周运行良好) 有关详细信息,请检查c:\Users\{user}\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml文件时出错Visual studio 2012 Windows Azure项目错误CctSharedPackage未正确加载,visual-studio-2012,azure,projects-and-solutions,Visual Studio 2012,Azure,Projects And Solutions,我打开了一个工作正常的解决方案文件,发现了这个神秘的错误 “CctSharedPackage”未正确加载 该项目是一个Windows Azure 2.1项目,上周工作时没有问题,但是从那时起到重新启动之间,它将无法再在Visual Studio 2012中成功加载。这发生在安装了Windows Azure SDK 2.1的计算机上(该项目上周运行良好) 有关详细信息,请检查c:\Users\{user}\AppData\Roaming\Microsoft\VisualStudio\11.0\Ac
在该文件中,它声明“找不到程序集Microsoft.Azure.Diagnostics ver 2.1”。鉴于已安装了Windows Azure SDK 2.1,我重新下载了安装程序并运行它,要求它重新安装或修复安装。由于安装是Web平台安装程序,因此它没有提供任何选项。此时,我决定必须卸载SDK才能从添加/删除程序重新安装它
当我去添加/删除程序时,我看到有针对.NET的WindowsAzure库-v1.8和WindowsAzure创作工具-v1.8的安装。我删除了这两个安装,然后项目能够成功加载 通过控制面板卸载了截至2012年10月的所有Windows Azure条目。在重新打开我的解决方案后,我得到了一个转换项目目标的对话框(屏幕截图)
我没有安装1.8 SDK。我相信是与.NET3.5相关的windows更新破坏了我的安装。要修复我所做的一切,只需在Windows 8中打开资源管理器,然后从功能区中选择“卸载或更改程序”选项
搜索Azure,当有“修复”选项时,我修复了该程序。修复了我遇到的类似问题(“CctSharedPackage”未正确加载)。在我的例子中,以管理员身份运行VisualStudio解决了这个问题 这似乎是安装程序的问题。重新安装是一个选项,但您可以通过在GAC中注册程序集,用简单的命令行修复它
C:\Program Files (x86)\Windows Azure Tools\Visual Studio 11.0>gacutil /i .\Microsoft.VisualStudio.WindowsAzure.Diagnostics.dll
我今天也遇到了这个问题,但对我来说幸运的是,重启VisualStudio2012就解决了这个问题。请至少尝试一次以确保:-) 我先关闭它,然后再打开选项。一周后加载项目时出现此错误。重新启动后,它就消失了。所以至少试一次。我也有同样的问题。重新安装SDK似乎没有什么帮助,重新安装Visual Studio听起来太痛苦了,所以我决定找出导致错误的原因 我使用了另一个VisualStudio实例,并附加它来调试有问题的VisualStudio实例。我看不到确切的错误发生在哪里,但我可以看到异常发生在哪个库中,并且可以使用.NET Reflector查看源代码,了解它的作用 启动时,Microsoft.Cct.CctSharedPackage库会迭代所有Azure SDK,以确定您的计算机上安装了哪些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);
}
}
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
运用系统反思;
使用系统文本;
使用System.Threading.Tasks;
命名空间控制台应用程序1
{
班级计划
{
静态void Main(字符串[]参数)
{
Console.WindowWidth=240;
//Microsoft.Cct.AssemblyResolver执行以下操作:
/*
private IEnumerable GetInstalledSDKsByProductVersionDesc(IServiceProvider服务提供商)=>
(来自AzureToolsVersionInfoUtilities.GetAllProducts()中的knownProduct)
其中knownProduct.TargetAzureSDK.issdk已安装()&&knownProduct.TargetAzureLibraries.islibrarieinstalled()
orderby knownProduct.ProductVersion降序
选择Known(产品)
*/
//使用反射复制此逻辑以查找已损坏的SDK安装。
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.azureToolsVersionInfo常量”);
//Console.WriteLine(典型的ToString());
var allMethods=typ.GetFields(BindingFlags.Static | BindingFlags.Public);
allMethods=allMethods.Where(it=>it.StartsWith(“WAT”)和&it.Length==5).OrderBy(it=>it.ToArray();
foreach(所有方法中的字符串版本)
{
var fld=typ.GetField(版本,System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
动态值=fld.GetValue(null);
var azTypeInfo=asm.GetType(“Microsoft.Cct.ProductVersionInfo.AzureToolsVersionInfo”);
bool-isSdkInstalled=false;
bool islibrarienstalled=false;
Dictionary sdkProperties=新字典();
Dictionary libProperties=new Dictionary();
//获取SDK引用
var targetAzureSDK=azTypeInfo.GetProperty(“targetAzureSDK”).GetValue(val);
键入targetAzureSDKProp=targetAzureSDK.GetType();
var methodNames=targetAzureSDKProp.GetMethods().Select(it=>it.Name).T