2

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

编辑:为了响应 Aaron 下面的建议,我运行了代码,结果如下:

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库存在不同或错误。

4

2 回答 2

4

我是为 Visual Studio 2010 编写 VSIX/扩展管理器的团队的开发人员,所以也许我可以在这里提供帮助。VSIX 文件是一个 OPC 容器(基本上是一个带有一些额外约束的 zip 文件)。如您所料,我们使用托管 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();
        }
    }
}
于 2011-03-29T16:12:06.793 回答
0

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

于 2011-03-16T09:17:36.240 回答