Assembly System.Data Not Found

I have a link to System.Data in my windows service project. I keep getting 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 specified file.

I am attaching FusionLog to my code and have learned the following. For System.Data , only the visual studio is viewed here:

Assembly Manager downloaded from: C: \ windows \ Microsoft.NET \ Framework \ v2.0.50727 \ mscorwks.dll

And it should look here (all other assemblies are System.Data)

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

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

I think Microsoft Commerce Server dll is referencing folder 2.0.

+6
source share
3 answers

Add this to app.config ..

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

If you need older versions of the DLL to load into the Windows service, you should add this. For web services, iis automatically takes care of this, but not for the Windows service.

+5
source

Make sure that your project is set to .Net Framework 4. If this is not the case, install it in the full profile (and not just for the client)

+2
source

If you select the reference assembly in the solution explorer, make sure that the version of the execution is correct (see the figure below). You can remove the link and add it again to correct it if necessary.

Also, if you are using app.config, make sure that it targets the correct version of execution.

enter image description here

+1
source

Source: https://habr.com/ru/post/916024/


All Articles