ASP.Net Core Web API Exception - Can't Find System.Data.Linq
-
I have an existing WPF app with a BL and DAL all written in .Net 4.5.2, I'm now trying to call the DAL from a new Asp.Net Core 5.0 Web API. I pass through the Controller into the BL fine, but when I hit the line that calls into the DAL it throws
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
System.Data.Linq isn't in the WPF app's bin folder because it's a .net assembly. I tried copying it into the Web API's Bin folder but that didn't work. Is there some problem with me calling a .Net 5 Core Wab API from a WPF app?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I have an existing WPF app with a BL and DAL all written in .Net 4.5.2, I'm now trying to call the DAL from a new Asp.Net Core 5.0 Web API. I pass through the Controller into the BL fine, but when I hit the line that calls into the DAL it throws
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
System.Data.Linq isn't in the WPF app's bin folder because it's a .net assembly. I tried copying it into the Web API's Bin folder but that didn't work. Is there some problem with me calling a .Net 5 Core Wab API from a WPF app?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
As far as I know, no, you cannot use a .NET Framework 4.5.2 .DLL in a .NET Core 5 app. You could migrate the 4.5.2 code to .NET Standard 2, then you could use it in both Framework and Core apps, but this solution is not ideal. You best solution would be to migrate your WPF and libraries to .NET Core 5.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
As far as I know, no, you cannot use a .NET Framework 4.5.2 .DLL in a .NET Core 5 app. You could migrate the 4.5.2 code to .NET Standard 2, then you could use it in both Framework and Core apps, but this solution is not ideal. You best solution would be to migrate your WPF and libraries to .NET Core 5.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave KreskowiakWow, that $ucks. The end goal is to stand up an API so I can hit it from both the WPF app and a Xamarin Forms app. I could still do this using a .Net Framework Web API.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I have an existing WPF app with a BL and DAL all written in .Net 4.5.2, I'm now trying to call the DAL from a new Asp.Net Core 5.0 Web API. I pass through the Controller into the BL fine, but when I hit the line that calls into the DAL it throws
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
System.Data.Linq isn't in the WPF app's bin folder because it's a .net assembly. I tried copying it into the Web API's Bin folder but that didn't work. Is there some problem with me calling a .Net 5 Core Wab API from a WPF app?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
LINQ to SQL has been effectively end-of-life since 2009. It was never ported to .NET Core or .NET 5/6/... The recommended workaround is to switch to using Entity Framework Core. But that's obviously a huge change, and will require a lot of testing, since some of your queries may no longer work, and the behaviour will be different in some cases. There's a third-party clone of L2S which is marked as .NET Standard 2.0, so it might work for you: NuGet Gallery | Mindbox.Data.Linq 5.0.0[^] GitHub - mindbox-moscow/data-linq: A clone of Microsoft System.Data.Linq to allow multi-DLL extensibility and EF compatibility.[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
LINQ to SQL has been effectively end-of-life since 2009. It was never ported to .NET Core or .NET 5/6/... The recommended workaround is to switch to using Entity Framework Core. But that's obviously a huge change, and will require a lot of testing, since some of your queries may no longer work, and the behaviour will be different in some cases. There's a third-party clone of L2S which is marked as .NET Standard 2.0, so it might work for you: NuGet Gallery | Mindbox.Data.Linq 5.0.0[^] GitHub - mindbox-moscow/data-linq: A clone of Microsoft System.Data.Linq to allow multi-DLL extensibility and EF compatibility.[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I could stand up a .Net Core API using a new DAL with EF and slowly port things over.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
Wow, that $ucks. The end goal is to stand up an API so I can hit it from both the WPF app and a Xamarin Forms app. I could still do this using a .Net Framework Web API.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
I'm convinced that Core is a steaming pile of shit. But that's just me. Now, instead of having one common assembly, I have to have two - one for framework, and one for whore core, which defeats the purpose of having a common library.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
LINQ to SQL has been effectively end-of-life since 2009. It was never ported to .NET Core or .NET 5/6/... The recommended workaround is to switch to using Entity Framework Core. But that's obviously a huge change, and will require a lot of testing, since some of your queries may no longer work, and the behaviour will be different in some cases. There's a third-party clone of L2S which is marked as .NET Standard 2.0, so it might work for you: NuGet Gallery | Mindbox.Data.Linq 5.0.0[^] GitHub - mindbox-moscow/data-linq: A clone of Microsoft System.Data.Linq to allow multi-DLL extensibility and EF compatibility.[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Instead of doing all that, just roll your own DAL and do either sql queries or stored procs to get/put data. You have much more control in a smaller package without having to understand or deal with how Microsoft thinks the world of database access should work. Generally speaking all ORM tools are garbage.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I'm convinced that Core is a steaming pile of shit. But that's just me. Now, instead of having one common assembly, I have to have two - one for framework, and one for whore core, which defeats the purpose of having a common library.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013#realJSOP wrote:
Now, instead of having one common assembly, I have to have two
Or have one that targets .NET Standard 2.0, which should generally work in .NET Framework 4.7.2 or later, .NET Core 2.0 or later, and .NET 5/6/etc. .NET Standard | Microsoft Docs[^] And if you really need to use features which aren't available in .NET Standard, you can target multiple frameworks in a single project[^] (so long as it's a new "SDK"-style project). It's a PITA, but it works.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
#realJSOP wrote:
Now, instead of having one common assembly, I have to have two
Or have one that targets .NET Standard 2.0, which should generally work in .NET Framework 4.7.2 or later, .NET Core 2.0 or later, and .NET 5/6/etc. .NET Standard | Microsoft Docs[^] And if you really need to use features which aren't available in .NET Standard, you can target multiple frameworks in a single project[^] (so long as it's a new "SDK"-style project). It's a PITA, but it works.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I just need to get an API up & running. I have no reason to target .Net Core, so .Net Framework would be fine.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I have an existing WPF app with a BL and DAL all written in .Net 4.5.2, I'm now trying to call the DAL from a new Asp.Net Core 5.0 Web API. I pass through the Controller into the BL fine, but when I hit the line that calls into the DAL it throws
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
System.Data.Linq isn't in the WPF app's bin folder because it's a .net assembly. I tried copying it into the Web API's Bin folder but that didn't work. Is there some problem with me calling a .Net 5 Core Wab API from a WPF app?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I could stand up a .Net Core API using a new DAL with EF and slowly port things over.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.