vb.net 应用程序在启动时崩溃 - 缺少 Microsoft.VisualBasic.PowerPacks
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17133879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application crashes on startup - missing Microsoft.VisualBasic.PowerPacks
提问by E Mett
I wrote a simple VB.NET application which works fine on the development machine.
我写了一个简单的 VB.NET 应用程序,它在开发机器上运行良好。
However on another machine, even though the .NET Framework is installed, it crashes on startup with System.InvalidOperationException.
然而,在另一台机器上,即使安装了 .NET Framework,它在启动时也会崩溃,并出现 System.InvalidOperationException。
There seems to be a problem with it finding the Visual Basic assemblies.
查找 Visual Basic 程序集似乎有问题。
Here is one of the fails (I replaced sensitive information with three dots):
这是失败之一(我用三个点替换了敏感信息):
*** Assembly Binder Log Entry (16/06/2013 @ 15:45:12) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\....
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/......
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSystemAdmin.exe
Calling assembly : MSystemAdmin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs.DLL.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs/Microsoft.VisualBasic.PowerPacks.Vs.DLL.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs.EXE.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs/Microsoft.VisualBasic.PowerPacks.Vs.EXE.
LOG: All probing URLs attempted and failed.
回答by Hans Passant
It isn't that clear why PowerPacks is missing, the .NET 4 Client Profile could be an issue. There have been multiple versions of PowerPacks around and the version numbering got to be a mess. On my machine, that same version is reported as v2.0.50727, even though it is stored in the GAC as version 10.0
不清楚为什么缺少 PowerPacks,.NET 4 Client Profile 可能是一个问题。周围有多个版本的 PowerPack,版本编号变得一团糟。在我的机器上,相同的版本被报告为 v2.0.50727,即使它作为版本 10.0 存储在 GAC 中
Best thing to do is to go back to your project. Click the "Show All Files" icon on the toolbar in the Solution Explorer window. That now shows the References node. Expand it and select the PowerPacks reference. In the Properties window, change the Copy Local property to True.
最好的办法是回到你的项目。单击“解决方案资源管理器”窗口中工具栏上的“显示所有文件”图标。现在显示参考节点。展开它并选择 PowerPacks 参考。在“属性”窗口中,将“复制本地”属性更改为 True。
Rebuild and your build directory now will have a copy of the DLL. Copy it along with the EXE onto the target machine.
重新构建,您的构建目录现在将拥有 DLL 的副本。将它与 EXE 一起复制到目标机器上。
回答by scarver2
Here is the URL to download Microsoft Visual Basic Power Packs 10.0
这是下载 Microsoft Visual Basic Power Packs 10.0 的 URL
回答by varocarbas
Apparently, it seems to be a problem with the "PowerPacks"; these are additional controls to the ones given by default in Visual Studio (in the form design part, under "Toolbox"). If you install the required packageon the target computer, everything should be fine.
显然,这似乎是“PowerPacks”的问题;这些是 Visual Studio 中默认提供的控件的附加控件(在表单设计部分,在“工具箱”下)。如果您在目标计算机上安装了所需的软件包,一切都应该没问题。
I had this problem in the past and my recommendation is not relying on these elements: they include nice-to-have features (in my case, it was an elliptic shape) but might be replaced with a bit of work and simpler objects. If you want to sell your program to a more or less wide audience, relying on this might become a problem: this package is not installed by default on virtually any computer and thus you would have to ask your clients to go ahead with the installation. Locating these specific controls is straightforward: on the "Toolbox" they should be listed under "PowerPacks" or similar.
我过去遇到过这个问题,我的建议并不依赖于这些元素:它们包括很好的特性(在我的例子中,它是一个椭圆形),但可能会被一些工作和更简单的对象所取代。如果您想将您的程序销售给或多或少的广泛受众,依赖于这一点可能会成为一个问题:默认情况下,几乎所有计算机上都不会安装此软件包,因此您必须要求您的客户继续安装。找到这些特定的控件很简单:在“工具箱”上,它们应该列在“PowerPacks”或类似的下面。
After reading the Hans Passant's comment, I do recall that a .dll file has to be put in the same directory than the executable, but I am under the impression that the PowerPacks package from the provided link has to be installed anyway (at least, on computers not having Visual Studio).
阅读 Hans Passant 的评论后,我确实记得必须将 .dll 文件放在与可执行文件相同的目录中,但我的印象是无论如何都必须安装所提供链接中的 PowerPacks 包(至少,在没有 Visual Studio 的计算机上)。
回答by DJohnston3
I was upgrading Visual Studio from Visual Studio 2013 to Visual Studio 2015 on a new Windows 10 machine. In doing so I copied my Projects folder from a Windows 7 machine to the same path on the Windows 10 machine.
我正在一台新的 Windows 10 机器上将 Visual Studio 从 Visual Studio 2013 升级到 Visual Studio 2015。在这样做时,我将我的 Projects 文件夹从 Windows 7 机器复制到 Windows 10 机器上的相同路径。
When I opened a project which used MS.VB.PowerPacks.VS I was informed the file could not be found. I downloaded the newest install for MS.VB.PowerPacks.VS Version 12.0.0.0. Visual Studio 2015 blanked out my form pages which used the PrintForm and informed me:
当我打开一个使用 MS.VB.PowerPacks.VS 的项目时,我被告知找不到该文件。我下载了 MS.VB.PowerPacks.VS 版本 12.0.0.0 的最新安装。Visual Studio 2015 清除了我使用 PrintForm 的表单页面并通知我:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.VS, Version 10.0.0.0.
System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.VisualBasic.PowerPacks.VS,版本 10.0.0.0。
I changed the reference to vcersion 12.0.0.0, but it was still not recognized.
我更改了对 vcersion 12.0.0.0 的引用,但仍然无法识别。
My fix: I copied the the C:\Program Files(x86)\Reference Assemblies\Microsoft\VBPowerPacks\v10.0
folder from my Windows 7 machine to my Windows 10 machine, and then removed the v12.0.0.0 reference and added the v10.0.0.0 reference to the program. I then exited the project and opened it again, and all was well, the forms were displayed in their original beauty.
我的修复:我将C:\Program Files(x86)\Reference Assemblies\Microsoft\VBPowerPacks\v10.0
文件夹从我的 Windows 7 机器复制到我的 Windows 10 机器,然后删除 v12.0.0.0 引用并将 v10.0.0.0 引用添加到程序。然后我退出项目并再次打开它,一切都很好,形式展示了它们原本的美丽。