0

I made an application using c#.net 2.0 and linq but as we can't use Linq cause it was introduced in framework 3.5, i add some references of dll of version 3.5 and linq started working fine.

when i made the setup and installed it, it is working fine on my system but on other system it is showing error that

Unable to load System.Data.DatasetExtensions

I don't know that if other dlls are working then why this dll is creating problem? What is the solution for this?

Needs Help.Thanks.

Mogli
  • 1,972
  • 11
  • 34
  • 67
  • 2
    Adding references to a .NET 3.5 library for a .NET 2.0 application is generally a bad idea. Are you sure you can't upgrade wholesale to .NET 3.5? – Jon Skeet Apr 10 '13 at 11:16
  • 2
    It's probably further dependencies of the LINQ assemblies. You'd do better upgrading the target runtime to 3.5 or removing the LINQ altogether I think. – Rup Apr 10 '13 at 11:16
  • FIrst, it's strange that you were able to reference the 3.5 dll from 2.0 one. I think you described not exactly what you've done. The second point - probablyt .NET 3.5 isn't installed at all on the other computer (where you are getting exception) – Sasha Apr 10 '13 at 11:16
  • @JonSkeet unfortunately i was told to make it for 2.0 from my senior :( – Mogli Apr 10 '13 at 11:18
  • Jon is right, by the way it may happen that .Net 3.5 is not installed on the other machine. – Babak Apr 10 '13 at 11:19
  • @OleksandrPshenychnyy i did this http://stackoverflow.com/questions/3348348/is-there-a-way-to-use-linq-query-syntax-with-net-3-0-projects – Mogli Apr 10 '13 at 11:20
  • 1
    Probably System.Data.DatasetExtensions is using some dlls from 3.5 which you have not referenced. Have you tried this http://www.albahari.com/nutshell/linqbridge.aspx? – Eli Algranti Apr 10 '13 at 11:21
  • @OleksandrPshenychnyy my application has 3 forms it shows two forms but throws error in 3rd form so that shows that that is not the issue of .net framework installation – Mogli Apr 10 '13 at 11:22
  • 1
    @harhar "i was told to make it for 2.0 from my senior" - it might be worth arguing this a little to see if you can get them to move; you've already done the work for 3.5 and tested it, so if you can convince them that 2.0 -> 3.5 is a low risk upgrade then it'll be quicker & cheaper to go with that. – Rup Apr 10 '13 at 11:30
  • @Rup yeah i think that's the only way i have,thanks. – Mogli Apr 10 '13 at 11:44

2 Answers2

4

If you are constrained to using .Net2.0, then don't bother trying to load assemblies targeting later versions of .Net. It's doomed to failure. If you want to use Linq, target >=.Net3.5, if you need to target .Net2.0, don't use Linq.

spender
  • 117,338
  • 33
  • 229
  • 351
1

Regarding error, the assemblies that you added may be having dependencies on other assemblies. It didn't give error on your system because you had it installed on it.

But you shouldn't be doing such a thing in general. A better way would be installing the required framework version within your installer as a pre-requisite requirement.

Ali
  • 1,409
  • 13
  • 23