ā Cannot find .dll in referenced project
I have a class library targetting .NET Standard 2.0. This library references two nuget packages: NETStandard.Library (2.0.3) and NetTopologySuite.IO.Esri.Shapefile (1.0.0).
The class library builds fine.
I then have a console app project in the same solution that targets .NET Framework 4.8.1. This project references the class library project. The console ap builds without warnings or errors. However, when running the app, as soon as I hit the first line that references the class library, I get the following error:
"Exception thrown: 'System.IO.FileNotFoundException' in NetFrameworkTestApp.exe
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in NetFrameworkTestApp.exe
Could not load file or assembly 'NetTopologySuite.Features, Version=2.0.0.0, Culture=neutral, PublicKeyToken=f580a05016ebada1' or one of its dependencies. The system cannot find the file specified."
Looking in the bin folder of the console app, I see the class library dll but not the two nuget packages' dlls. The dlls do exist in the bin of the class library. What am I missing here?
16 Replies
What does your program's csproj look like?
BTW you probably shouldn't need to reference this thing:
Also does this file exist anywhere?
Do you want the whole csproj file? Here's the part referencing my class library:
<ItemGroup>
<ProjectReference Include="..\HuginFileProcessor\ShapefileTestingLib.csproj">
<Project>{0334C783-9937-4C44-824D-624CD0362332}</Project>
<Name>ShapefileTestingLib</Name>
</ProjectReference>
</ItemGroup>
And here is what the dependencies looks like for my ShapefileTestingLib class library:Oh god, is that the old csproj format? š±
Change to the new SDK format
I have no idea lol. It's just what vs 2022 made when I picked to create a class library project
this a console app?
yup
weird how it mentions it can't find 2.0.0.0 but I don't see that referenced anywhere
Run
dotnet new console --name MyProject
in a different folder, then copy the csproj it generate over. Edit it in a text editor and change the TargetFramework to net481 or whatever.
Then open it in Visual Studio and add back your project references.
The old csproj format is garbage.
Or send me the project on github or something and I can convert it in about 10 seconds š
I migrated more than 600 projects to the new SDK format, it's ingrained in my muscle memory now.hmm does net48 cover 4.8.1? don't see net481 listed https://learn.microsoft.com/en-us/dotnet/standard/frameworks
Target frameworks in SDK-style projects - .NET
Learn about target frameworks for .NET apps and libraries.
This builds fine for me
ĀÆ\_(ć)_/ĀÆ
š it worked using the newer format
thank youuu. I would have never thought of that
When the SKD builds the new format it enables "transitive" references where dependencies of things you reference get pulled in automatically.
The fact that VS is stil using the old format for newly created .NET Framework projects is deeply sad.
I guess nobody is focusing on .NET Framework since it's considered a technological dead end at this point.
oh wow, that is good to know because my employer is still using mostly .net framework apps (slowly moving to .net 6 though!)
There are few good reasons to use .NET Framework these days.
Like if it's a new project I would never target Framework.
Except maybe in some very specific circumstances where you don't want to or can't install the .NET runtime on your target Windows machines.
yeah apparently one of our users thought they had .net 6 installed but it was actually just esri .net 6 dlls, and it's a months long process to get anything new installed š
oh well. thanks again š
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.