Search code examples
c#.net-assemblysystem.data

System.Data Assembly Not found


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

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

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

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

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?

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


Solution

  • Add this to 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.