C
C#2y ago
Aurelius

✅ Ported an app to .NET 7, rebuild all my dependencies, app refuses to load them

READ THIS FIRST: I tried all the typical debugging methods such as assembly binding logs and whatnot, to little to no results. This isn't easily solved with google. Hey everyone, I was porting an app to .NET 7 (from .net framework 4.6), and I keep having an assembly not found exception from my dependencies. I tried ProcMon and tools that show me the assembly binding failures, but for some reason nothing shows there. I also tried Dependency Walker but it just freezes while loading them. I'm not sure if the host that runs the app (since modern .NET uses an app host to actually run the app) is preventing this from going to logs and therefore it's being very hard to debug. I also have other issues with VS2022, where it either randomly (not always) fails to build due to metadata file missing for my main dependency (even tho it's being built in one of the projects that errors with that, multiple attempts to build usually "fix" that), and also where the main dependency's project shows warnings about the types I create there being found in two places (which are the dependency in both cases). I tried doing dotnet publish for the 3rd party dependencies, so not sure if that's related? I'd really appreciate some help here as I never went beyond .NET Framework until now. Thank you very much for your help!
39 Replies
ero
ero2y ago
can you tell us exactly what the errors are?
Aurelius
AureliusOP2y ago
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'glfwnet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'glfwnet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Staple.RenderWindow.Create(Int32 width, Int32 height, Boolean resizable, WindowMode windowMode, AppSettings appSettings, Int32 monitorIndex, ResetFlags resetFlags)
at Staple.AppPlayer.Run() in C:\Git\StapleEngine\Engine\Core\Player\AppPlayer.cs:line 144
at Staple.StaplePlayer.Run(String[] args) in C:\Git\StapleEngine\Engine\Core\Player\StaplePlayer.cs:line 7
at Staple.Program.Main(String[] args) in C:\Git\StapleEngine\Engine\Player\Program.cs:line 9
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'glfwnet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'glfwnet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Staple.RenderWindow.Create(Int32 width, Int32 height, Boolean resizable, WindowMode windowMode, AppSettings appSettings, Int32 monitorIndex, ResetFlags resetFlags)
at Staple.AppPlayer.Run() in C:\Git\StapleEngine\Engine\Core\Player\AppPlayer.cs:line 144
at Staple.StaplePlayer.Run(String[] args) in C:\Git\StapleEngine\Engine\Core\Player\StaplePlayer.cs:line 7
at Staple.Program.Main(String[] args) in C:\Git\StapleEngine\Engine\Player\Program.cs:line 9
I know this can happen from a missing dependency inside the dependency (glfwnet in this case depends on glfw but glfw is in the same folder)
ero
ero2y ago
how do you mean "in the same folder"? are these not 2 projects in the same solution?
Aurelius
AureliusOP2y ago
glfwnet in this case is a separate dependency I built, not in the same solution however glfwnet is located in the same working directory folder for the project in the solution
Angius
Angius2y ago
So it's some random loose .dll?
Aurelius
AureliusOP2y ago
so the Player should be able to see it yeah but for some reason I can't get an answer as to which DLL it is it's also set as a dependency of the Player project, so it's copied around on build
ero
ero2y ago
what is this project setup lol
Aurelius
AureliusOP2y ago
assembly binding logs don't show for this, and dependency walker freezes when analysing the DLL it's a game engine, I got a dependencies solution for building 3rd parties, and a Engine solution for building the main engine projects the engine solution has the Player, Core, Editor, and Editor App both the Editor App and Player fail to run due to this error
Angius
Angius2y ago
Well, I won't be of much help. I never reference loose .dlls, I either use Nuget for dependencies, or just reference the project itself
Aurelius
AureliusOP2y ago
it's likely a native dependency that's failing to load this error can appear when an assembly's dependency fails to load
ero
ero2y ago
is this a runtime error?
Aurelius
AureliusOP2y ago
yeah
ero
ero2y ago
then... i guess the .dll is just not set to copy to output...?
Aurelius
AureliusOP2y ago
the related DLLs should all be copied directly to this folder problem is I can't figure out which DLL is missing because the tools I would use to figure this out aren't working the assembly binding log is empty, and dependency walker freezes
ero
ero2y ago
it's really not clear at all what you're doing
Aurelius
AureliusOP2y ago
okay I built my project all the dependencies are in the spot when I try to open it, it fails to run due to a dependency not loading I can't figure out why because the tools you would use for this don't work for giving details of the problem
ero
ero2y ago
What project. What are you building. What's the full setup. What dependency is missing. Where are you getting it. Why could it be failing. So much info missing
Aurelius
AureliusOP2y ago
^ I'm using VS 2022 and C# some dependencies are native and are imported as native DLLs I don't know what dependency is missing, because the tools I used so far don't tell me however I just used asmspy to list my assembly references at least and solved some of the problem now only one of the projects doesn't work Newtonsoft.Json was for .NET 6 while I was using .NET 7, so I recompiled it to 7 and now at least the Player project works. the Editor project still doesn't work unfortunately.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ero
ero2y ago
Oh what the fuck. I thought that glfwnet project was the one they're making See this is what happens if you don't explain properly
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ero
ero2y ago
you can't even have a "native" dependency in c# can you? or would you consider a library that you P/Invoke a "dependency"?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Aurelius
AureliusOP2y ago
Glfwnet depends on glfw to work, and at least at the time didn't have net7 version Newtonsoft json also doesn't have a net7 version on nuget
ero
ero2y ago
why should it? why would you use it, anyway? newtonsoft has a net6.0 version, that's gonna work just fine with net7.0
Aurelius
AureliusOP2y ago
Newtonsoft was failing to load for me
ero
ero2y ago
that's a you thing it definitely works but you don't even want to use newtonsoft in net7.0 it's absolute dogshit (and that's putting it lightly) compared to STJ on that version
Aurelius
AureliusOP2y ago
Newtonsoft was failing to load because I had two assemblies using two different versions of another assembly (since newtonsoft was 6 and my other assembly 7)
ero
ero2y ago
doesn't make sense
Aurelius
AureliusOP2y ago
I already tried using asmspy, ilspy, procmon, fusion, dependency walker, and I still can't figure out why my editor DLL won't load I even tried removing most of its code and it still doesn't work the only dependency it has is my Core project, which works since my Player project runs
ero
ero2y ago
do you wanna share literally any part of your project setup any code your project files anything at all
Aurelius
AureliusOP2y ago
GitHub
GitHub - LittleCodingFox/StapleEngine at feature/net7
Contribute to LittleCodingFox/StapleEngine development by creating an account on GitHub.
ero
ero2y ago
yeah this is a very... unusual? project setup... you include dependencies using their built binaries, what are you doing just use nuget packages
Aurelius
AureliusOP2y ago
the nuget packages don't have net7 versions
ero
ero2y ago
it doesn't matter
Aurelius
AureliusOP2y ago
it was failing to load, so it does matter
ero
ero2y ago
if they're compatible, they're compatible it does not matter. You're clearly messing something else up in your project setup for it to not work
Accord
Accord2y ago
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.
Aurelius
AureliusOP2y ago
I accidentally figured out the cause: Apparently, dotnet projects don't like having their bin/obj shared. By moving the projects to each source subfolder, all the problems seem to have been fixed!
Want results from more Discord servers?
Add your server