Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In some cases, Netbeauty2 may cause the same dll to be loaded multiple times #49

Open
bodong1987 opened this issue Mar 9, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@bodong1987
Copy link

dll-loaded-repeat.mp4

MyTests.zip
1.TestLibs is a public library that is referenced by other projects.
2.TestPlugin, simulation plug-in dll, dynamic loading, direct reference to TestLibs
3. TestConsoleWithRef directly references TestLibs and uses NetBeauty for directory optimization
4.TestConsole, load TestLibs through Assembly.LoadFile and call its methods.

When running with TestConsole, you will see TestLibs.dll loaded twice.
It's not clear to me if this is expected, if Assembly.LoadFile must be used to briefly reference TestLibs, is there a solution to this problem?

@liesauer
Copy link
Member

image

i can't reproduce it even do everything exactly the same as the video, but after analyzing the project structure, but i guess here should be what things happened

  1. TestConsole and TestConsoleWithRef are one with NetBeauty and one without NetBeauty
  2. after building entire solution, both two projects files are mixed into the same output folder
  3. running the ncbeauty post build task, it will search every single *.deps.json and *.runtimeconfig[.dev].json and process them, so TestConsole is beauty unexcpedly too.
  4. ncbeauty injects a STARTUP_HOOK calls nbloader which will add a resolver to the default AssemblyLoadContext.
  5. TestLibs also adds a resolver to the current AppDomain
  6. TestLibs was loaded twice in somehow

btw:
the project structure is kind of wired, TestConsole is trying to load the TestLibs and TestLibs is trying to load the TestPlugin and TestPlugin is referencing the TestLibs.

ps:
NetBeauty has the concept of project since it is a msbuild task, but ncbeauty hasn't unless treats every different *.deps.json as a different project, but this behaviour should treat as a BUG.

@liesauer
Copy link
Member

you can post a copy of debug build bins with pdb so i can have a deep look.

@liesauer liesauer added the bug Something isn't working label Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants