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

External references/packages are incorrectly included in to the compiled DLL #154

Open
Jesse-Schokker opened this issue May 31, 2020 · 1 comment
Labels

Comments

@Jesse-Schokker
Copy link

Jesse-Schokker commented May 31, 2020

Hey,

I am using DllExport for this project and I need a library (Newtonsoft.Json) that serialized JSON for me. As usual, I install it using NuGet. However, when using it inside my Java projects it crashes due to it not being able to find the dependency. As a double check I created another .NET project and simply just referenced the built DLL from there and got the same result. Whenever I use the DLL that is not generated by DllExport it works fine. Only the DLL built using DllExport has this issue.

I've checked the DLL that was generated using a dependency inspector tool ( https://github.com/lucasg/Dependencies ) and it seems like the dependency is registered however it is not found as you can see here:

I have attached the build log and full project.

Steps to reproduce:

  • DllExport -version: 1.7.1
  • Used Visual Studio / MSBuild / : Visual Studio 2019 / Jetbrains Rider 2020.1

Information from Data tab or log data:

build_new.txt

Demo Project files / Samples / etc.:

GDBridgeProject.zip

@3F
Copy link
Owner

3F commented May 31, 2020

Thanks for the updated information. I will continue our discussion from twitter here.

For the problem with DependenciesLib

This looks similar to #136 where problem is also due to the used third-party tool.

I've quickly inspected mentioned tool and this is it:

https://github.com/lucasg/Dependencies/blob/eb144c9b91561fb84a456d43ba2d5b9942c18aaf/DependenciesLib/FindPeModule.cs#L87

((TestPe.LoadSuccessful) && (TestPe.GetProcessor() == ProcessorArch))
.............................^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For the case with Newtonsoft.Json.dll it will return different arch because it was written for 80386 (anycpu for this case regarding CLR) while parent modified module may point to other (see ResolveModule(PE RootPe,... ).

Therefore, you may also note the correct resolving for x86 but not for x64.

Also noticed they used value from offset 0x84, not from offset 0x98 (it could be more clear for resolving in CLR context).

Anyway, you need to report there because this is not related to .NET DllExport.

For the problem with Java

when using it inside my Java projects it crashes due to it not being able to find the dependency.

Again, make sure that all dependencies are accessible to load with correct architecture. But seems like this is duplicate of #101

AssemblyResolve is one of the possible solutions. You can also try Pre-processing same as for Conari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants