未找到 System.Data 程序集 [英] System.Data Assembly Not found

查看:40
本文介绍了未找到 System.Data 程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Windows 服务项目中有一个对 System.Data 的引用.我不断收到 Exception :

I have a reference to System.Data in my windows service project. I keep getting the Exception :

无法加载文件或程序集System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"或其依赖项之一.系统找不到指定的文件.

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.

我将 FusionLog 附加到我的代码中并发现以下内容.对于 System.Data,只有 Visual Studio 在这里查看:

I attach the FusionLog to my code and found out the following. For System.Data only visual studio is looking here:

程序集管理器加载自:C:windowsMicrosoft.NETFrameworkv2.0.50727mscorwks.dll

Assembly manager loaded from: C:windowsMicrosoft.NETFrameworkv2.0.50727mscorwks.dll

它应该在这里查看(所有其他程序集都只是 System.Data)

And it should be looking here (all the other assemblies are but System.Data)

程序集管理器加载自:C:windowsMicrosoft.NETFrameworkv4.0.30319clr.dll

Assembly manager loaded from: C:windowsMicrosoft.NETFrameworkv4.0.30319clr.dll

如何将 System.Data 文件指向正确的位置?

How can I do point my System.Data file to look in the right place?

我的猜测是 Microsoft Commerce Server dll 可能引用了 2.0 文件夹.

My guess is Microsoft Commerce Server dlls are referenceing the 2.0 folder maybe.

推荐答案

将此添加到 app.config..

Add this to app.config..

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>

如果您需要在 Windows 服务中加载旧版本的 dll,您必须添加它.对于 Web 服务,iis 会自动处理它,但不适用于 Windows 服务.

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.

这篇关于未找到 System.Data 程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆