C# 未找到 System.Data 程序集
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10641958/
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
System.Data Assembly Not found
提问by Nick LaMarca
I have a reference to System.Datain my windows service project. I keep getting the Exception:
我System.Data在我的 Windows 服务项目中有一个参考。我不断得到Exception:
Could not load file or assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集“System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或其依赖项之一。该系统找不到指定的文件。
I attach the FusionLogto my code and found out the following. For System.Dataonly visual studio is looking here:
我将 附加FusionLog到我的代码并发现以下内容。对于System.Data只有Visual Studio是寻找在这里:
Assembly manager loaded from: C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
从以下位置加载的程序集管理器:C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
And it should be looking here (all the other assemblies are but System.Data)
它应该在这里查看(所有其他程序集都只是 System.Data)
Assembly manager loaded from: C:\windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
从以下位置加载的程序集管理器:C:\windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
How can I do point my System.Datafile to look in the right place?
我怎样才能将我的System.Data文件指向正确的位置?
My guess is Microsoft Commerce Serverdlls are referenceing the 2.0 folder maybe.
我的猜测是Microsoft Commerce Serverdll 可能引用了 2.0 文件夹。
采纳答案by Nick LaMarca
Add this to app.config..
将此添加到 app.config..
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
If you need old versions of dlls to be loaded in a windows service you must add this. For web services iis automatically takes care of it, but not for windows service.
如果您需要在 Windows 服务中加载旧版本的 dll,您必须添加它。对于 Web 服务,iis 会自动处理它,但不适用于 Windows 服务。
回答by Otávio Décio
Make sure your project is set to .Net Framework 4. If that doesn't do it, set it to full profile (not just Client)
确保您的项目设置为 .Net Framework 4。如果不这样做,请将其设置为完整配置文件(不仅仅是客户端)
回答by BryanJ
If you select the referenced assembly in the solution explorer, verify that the runtime version is correct (see image below). You can remove the reference and re-add it to fix it if necessary.
如果您在解决方案资源管理器中选择引用的程序集,请验证运行时版本是否正确(请参见下图)。如有必要,您可以删除引用并重新添加以修复它。
Also, if you are using an app.config, make sure it is targeting the correct runtime version.
此外,如果您使用的是 app.config,请确保它针对正确的运行时版本。



