尝试为Visual Studio 2010安装Productivity Power Tools时出错

时间:2011-03-16 09:12:51

标签: visual-studio visual-studio-2010 productivity-power-tools

我尝试过两台不同的机器,并尝试过多次下载,但每当我尝试在VS 2010 Premium(10.0.30139.1 RTMRel)中安装Productivity Power Tools扩展时,我都会收到错误“该文件不是有效的VSIX包。“搜索显示只有一两个人遇到过这个问题。我该如何诊断这个问题?

编辑:为了回应下面关于亚伦的建议,我运行了以下结果的代码:

at MS.Internal.IO.Zip.ZipIOLocalFileDataDescriptor.ParseRecord(BinaryReader reader, Int64 compressedSizeFromCentralDir, Int64 uncompressedSizeFromCentralDir, UInt32 crc32FromCentralDir, UInt16 versionNeededToExtract)
at MS.Internal.IO.Zip.ZipIOLocalFileBlock.ParseRecord(BinaryReader reader, String fileName, Int64 position, ZipIOCentralDirectoryBlock centralDir, ZipIOCentralDirectoryFileHeader centralDirFileHeader)
at MS.Internal.IO.Zip.ZipIOLocalFileBlock.SeekableLoad(ZipIOBlockManager blockManager, String fileName)
at MS.Internal.IO.Zip.ZipIOBlockManager.LoadLocalFileBlock(String zipFileName)
at MS.Internal.IO.Zip.ZipArchive.GetFile(String zipFileName)
at MS.Internal.IO.Zip.ZipArchive.GetFiles()
at System.IO.Packaging.ZipPackage.ContentTypeHelper..ctor(ZipArchive zipArchive, IgnoredItemHelper ignoredItemHelper)
at System.IO.Packaging.ZipPackage..ctor(Stream s, FileMode mode, FileAccess access, Boolean streaming)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess)
at VSIXReadTest.Program.Main(String[] args) in C:\\Development\\WebSockets\\PowerTools\\Program.cs:line 17

我已多次下载该文件,每个文件都有相同的结果,向我建议我的文件系统或Packaging库存在不同或错误。

2 个答案:

答案 0 :(得分:4)

我是为Visual Studio 2010编写VSIX / Extension Manager的团队的开发人员,所以也许我可以在这里提供帮助。 VSIX文件是一个OPC容器(基本上是一个带有一些额外约束的zip文件)。正如您所料,我们使用Managed OPC API来打开文件(即.NET中的System.IO.Packaging命名空间)。只有在对ZipPackage.Open的调用失败时才会出现此错误消息。

您是否可以尝试将以下代码编译到计算机上的C#控制台应用程序(目标为.NET 4.0)并查看结果?您还需要向WindowsBase添加程序集引用。如果这里有错误,我们当然希望了解更多信息!

namespace VSIXReadTest
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.IO.Packaging;

    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                const string PathToVsixFile = @"PutPathHere!!!";
                using (FileStream stream = new FileStream(PathToVsixFile, FileMode.Open, FileAccess.Read))
                {
                    Package vsixPackage = ZipPackage.Open(stream, FileMode.Open, FileAccess.Read);
                }
            }
            catch (Exception ex)
            {
                StringBuilder errorMessage = new StringBuilder();
                do
                {
                    errorMessage.Append(ex.GetType().Name);
                    errorMessage.Append(": ");
                    errorMessage.AppendLine(ex.Message);
                    errorMessage.AppendLine(ex.StackTrace);
                    ex = ex.InnerException;
                } while (ex != null);

                Console.WriteLine(errorMessage.ToString());
            }

            Console.WriteLine("Press a key to exit...");
            Console.Read();
        }
    }
}

答案 1 :(得分:0)

<。> .VSIX文件实际上是.ZIP文件的底层。尝试重命名它,看看你里面有什么。也许这只是一个损坏的下载问题?我自己尝试过这个链接http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/,似乎工作正常。