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

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

问题描述

我在Windows服务项目中引用了 System.Data 。我一直收到 Exception

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


无法加载文件或程序集'System。数据,版本= 4.0.0.0,文化=中性,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:\windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll

Assembly manager loaded from: C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll

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

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


从以下位置加载的程序集管理器:C:\windows\Microsoft。 NET\Framework\v4.0.30319\clr.dll

Assembly manager loaded from: C:\windows\Microsoft.NET\Framework\v4.0.30319\clr.dll

我该如何指向我的系统数据文件查找在正确的位置?

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>

如果需要将旧版本的dll加载到Windows服务中,则必须添加它。对于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天全站免登陆