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

Copy of native DLL does not work for restricted processes #892

Open
rima1098 opened this issue May 16, 2024 · 3 comments
Open

Copy of native DLL does not work for restricted processes #892

rima1098 opened this issue May 16, 2024 · 3 comments

Comments

@rima1098
Copy link

Describe the bug
As far as I've seen this in the code, the native library is copied to the parent directory.

CopyFileIfNewer(nativeFilePath, targetPath);

This works on our development machines but when deploying software on ISS e.g. we run the process with reduced privileges and it is therefore not allowed to copy files to the parent directory. We are not able to allow the process to do this as it bears security risks.
The issue leads to the exception that the QuestPDFSkia.dll cannot be accessed as it is not present.

Expected behavior
Working with QuestPDF should be possible without giving copy previleges to the process.

Environment
2024.3.6 x64 (Professional License)

Additional context
I assume the copying is necessary to find the correct .dll depending on the runtime. Maybe you can find some other way to resolve the library without copying?

@MarcinZiabek
Copy link
Member

MarcinZiabek commented May 20, 2024

Could you please share more details about your application? Does it use the legacy .NET Framework or the modern .NET 5 and beyond?

Technically, the native files should be loaded automatically by .NET. However, for some applications, this does not happen for no apparent reason. Copying files is a last-resort approach to make the library work.

@rima1098
Copy link
Author

Ah I see, we are indeed using legacy .NET Framework (net472). I was not aware that this is only executed as a fallback. We did a workaround with a copy job in our pipeline, guess we will stick to that then :D

@MarcinZiabek
Copy link
Member

I experienced this issue even for two identical projects in the same solution. One was working, and one was not.

I will investigate additional steps in the msbuild .targets file that can also perform the copy operation during the build process. The only difficulty is that the target runtime needs to be known during this step.

Essentially, it requires the following code in the .csproj file, which I believe could be missing in many projects. Thus, making this solution of little value.

<PropertyGroup>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier> <!-- or win-x86 -->
</PropertyGroup>

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

No branches or pull requests

2 participants