Error due to another version of .net?

class Program { static string path = "C:\\Work\\6.70_Extensions\\NightlyBuild\\"; static void Main(string[] args) { var di = new DirectoryInfo("C:\\Work\\6.70_Extensions\\NightlyBuild"); foreach (var file in di.GetFiles("*", SearchOption.AllDirectories)) file.Attributes &= ~FileAttributes.ReadOnly; var files = Directory.GetDirectories(path, "SASE Lab Tools.*"); foreach(var file in files) Console.WriteLine(file); foreach(var file in files.OrderByDescending(x=>x).Skip(7)) Console.WriteLine(file); foreach(var file in files.OrderByDescending(x=>x).Skip(7)) Directory.Delete(file); } } 

This is my code that I executed in VS2008.net version 3.5. However, when I transfer this to another machine with .net version 3.0, an error occurred even in the same environment.

Error:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I do not have VS2008 installed on this machine, and I was wondering if my code has anything to do with this error? I tried switching to msdn and exploring the Directory.GetDirectories directory (string, Searchpattern) and only this appeared for 3.5

+4
source share
5 answers

It does not work, because the v3.5 framework is not installed, and your executable file references the assemblies that are included in it to support the LINQ query in this fragment. Either install v3.5 in the framework (or later), or change the application to the target lower version of the framework (which would mean that you would have to rewrite the LINQ query as "normal" code)

+2
source

Install .NET 3.5 on another computer ...
The error message could not be clearer: you linked your program with the .NET 3.5 DLL, but they are not installed, so you get an error message.

+2
source

You are using a DLL, which is part of version 3.5 for the framework. To do this, of course, you will need this DLL on the client PC.

+1
source

Code like files.OrderByDescending(x=>x).Skip(7) uses LINQ, which is located in System.Core, which is installed with 3.5 and higher. Therefore, either install the .NET Framework 3.5, or (if you cannot) replace the mentioned fragment with your own selection method.

+1
source

You need to change your program to use .net 3.0 (and then replace GetDirectories with some other function) or install .net 3.5 wherever you want to use your program.

0
source

All Articles