1

I'm facing a compatibility issue for .NET project. I have 2 projects:

  • 1st project: Libary project. Target: windows Phone 7.0 OS version project
  • 2nd project: Console Appplication project. Refers/use the previous library. Target: Framework .NET 3.5

When I try to run the 2nd project, I have an exception that happens when I call a function from the 1st library:

...Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7xxxxxxxx or one of its dependencies. The system cannot find the file specified...

If I change the target for 2nd project to Framework .NET 4.0, it works well, no more crash.

Is my error really due to the different target versions ? How can I make the 1st project to be compatible with framework 3.5 ?

hico
  • 1,850
  • 1
  • 19
  • 28
  • There is *incredibly* little reason to target a phone version that absolutely nobody uses anymore. Or to expect it to magically work with an ancient desktop version of the framework. It fails because that library requires the CLR to support re-targeting, that's a .NET 4 feature. Only way to make it compatible is to stop assuming that Phone70 is a useful target, the library must target 3.5 as well. Don't get stuck on ancient versions of free software, there is no point. – Hans Passant Oct 22 '15 at 10:31
  • Possible duplicate of [Could not load file or assembly or one of its dependencies](http://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies) – anmarti Oct 22 '15 at 10:31
  • Yes, agree that 7.0 is outdated, but even when upgrading to 8.0, it does not change anything about the problem. However, fixed with the solution below – hico Oct 22 '15 at 14:48

2 Answers2

0

As I said, 1st project was targeting framework 3.5 .NET and 2nd project was targeting Windows Phone 7.0.

Work around: change 2nd project to target framework 3.5 .NET. (in my case, I add to create a new project in my solution, which in fact was the same as the old one but targeting framework 3.5 .NET. Same sources used.)

Kindly rough but works.

hico
  • 1,850
  • 1
  • 19
  • 28
-1

I had excactly same issue. Installing Portable Class Library helped me.

https://msdn.microsoft.com/en-us/library/gg597391.aspx

There are links to downloads for different visual studio versions.

m3f
  • 81
  • 5