asp.net-mvc 无法加载文件或程序集 'WebMatrix.Data,版本 = 3.0.0.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23181104/
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
Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0
提问by Jagmohan Kasana
Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集“WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。
回答by pwdst
Is this a solution that you have created or one you have downloaded (as a sample or as work done by a colleague)? Do you have an up to data version of NuGet installed within Visual Studio and have you checked installed packages for the project - you may need to restore packages if you have downloaded the solution from Source Control or as a zip sample online.
这是您创建的解决方案还是您下载的解决方案(作为示例或作为同事完成的工作)?您是否在 Visual Studio 中安装了最新的 NuGet 数据版本并检查了项目的已安装包 - 如果您已从源代码管理下载解决方案或作为在线 zip 示例,您可能需要还原包。
The easiest way to do this is to check that NuGet Package Manager is up to date in "Tools" > "Extensions and Updates" and then (with the applicable project selected in Visual Studio) select "Project" > "Manage NuGet Packages". If there are installed Packages which are not found in your solution packages directory then NuGet should offer to restore them for you.
最简单的方法是在“工具”>“扩展和更新”中检查 NuGet 包管理器是否是最新的,然后(在 Visual Studio 中选择适用的项目)选择“项目”>“管理 NuGet 包”。如果在您的解决方案包目录中找不到已安装的包,则 NuGet 应提供为您还原它们。
Alternatively you may have added a package which has a dependency on that package, and you either do not have it installed or have a previous version.
或者,您可能添加了一个依赖于该软件包的软件包,而您要么没有安装它,要么有以前的版本。
To install the package within NuGet Package Manager Console type-
要在 NuGet 包管理器控制台中安装包,请键入-
Install-Package Microsoft.AspNet.WebPages.Data
安装包 Microsoft.AspNet.WebPages.Data
Or search for "Microsoft.AspNet.WebPages.Data" in the "Manage NuGet Packages" window, accessed via the instructions above.
或者在“管理 NuGet 包”窗口中搜索“Microsoft.AspNet.WebPages.Data”,通过上述说明访问。
If you have a prior version of the package installed, you may need to remap that version number to the version 3.0.0.0 with the following code in your project config (most likely Web.config) file in order to avoid breaking packages with dependencies on the previous version-
如果您安装了该软件包的先前版本,您可能需要使用项目配置(最有可能是 Web.config)文件中的以下代码将该版本号重新映射到版本 3.0.0.0,以避免破坏依赖于之前的版本——
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
回答by Dmitry
I had a similar problem, and I fixed it by doing the following:
我有一个类似的问题,我通过执行以下操作来解决它:
Installing the package via package manager console(from visual studio) Use the following commands:
PM> Install-package WebMatrix.Data
PM> Install-package WebMatrix.WebData
Add a binding Redirect in Web.config file Between <runtime></runtime> tags:
<dependentAssembly> <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly>
通过包管理器控制台(来自visual studio)安装包使用以下命令:
PM> 安装包 WebMatrix.Data
PM> 安装包 WebMatrix.WebData
在 Web.config 文件中的 <runtime></runtime> 标记之间添加绑定重定向:
<dependentAssembly> <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly>
3.I've copied both dlls from: /YourProject/packages folder to /YourProject/bin folder
3.我已将两个 dll 从:/YourProject/packages 文件夹复制到 /YourProject/bin 文件夹
(Optional) If you can't find the dlls in /YourProject/packages folder, try search for the dlls in /YourProject/bin/Debug folder, and copy/Paste them into /YourProject/bin folder instead.
(可选)如果在 /YourProject/packages 文件夹中找不到 dll,请尝试在 /YourProject/bin/Debug 文件夹中搜索 dll,并将它们复制/粘贴到 /YourProject/bin 文件夹中。
It solved the problem for me.
它为我解决了这个问题。
回答by John Gilmer
The only thing that worked for me was editing the properties of the DLL (right-click the WebMatrix.WebData DLL in solution explorer and select Properties), changing the "Copy Local" property to true. Same for the WebMatrix.Data DLL.
唯一对我有用的是编辑 DLL 的属性(在解决方案资源管理器中右键单击 WebMatrix.WebData DLL 并选择属性),将“复制本地”属性更改为 true。WebMatrix.Data DLL 也是如此。
回答by Parag
Following solution helped us
以下解决方案帮助了我们
step 1: Delete the service reference and build the app (will show error) step 2: Add service reference again -> click on advance button step 3: uncheck "Reuse types in referenced assemblies" and then click on OK step 4: Rebuild the application
第 1 步:删除服务引用并构建应用程序(将显示错误) 第 2 步:再次添加服务引用 -> 单击前进按钮 第 3 步:取消选中“在引用的程序集中重用类型”,然后单击“确定”第 4 步:重新构建应用

