Skip to content

Fix unit tests native dependencies #10338

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

Merged

Conversation

ThomasGoulet73
Copy link
Contributor

@ThomasGoulet73 ThomasGoulet73 commented Jan 26, 2025

This is a workaround for dotnet/runtime#111825

Description

Fixes errors in unit tests when trying to load wpfgfx_cor3.dll which depends on D3DCompiler_47_cor3.dll which can't be found at runtime which seems to be caused by a bug in the runtime when using DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.System32 as the search path.

This search path is the default search path used by all projects in this repo and it's configured here:

<ExtendedAssemblyInfo Include="DefaultDllImportSearchPaths"
Condition="'$(IncludeDllSafeSearchPathAttribute)'=='true'">
<Parameter1>DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.System32</Parameter1>
<IsLiteral1>true</IsLiteral1>
</ExtendedAssemblyInfo>

We can't just set IncludeDllSafeSearchPathAttribute to false in the test projects since the attribute is used to configure the search path used by default for each assembly. We would need to set it to false for all assemblies trying to load wpfgfx_cor3.dll.

This problem does not occur for apps using WPF, see the issue for more info

Customer Impact

None, test only.

Regression

No.

Testing

Local build + CI + local test.

Risk

None, test only.

Microsoft Reviewers: Open in CodeFlow

@ThomasGoulet73 ThomasGoulet73 requested review from a team as code owners January 26, 2025 23:49
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jan 26, 2025
@ThomasGoulet73
Copy link
Contributor Author

@dipeshmsft: This is the workaround I was talking about here: #10304 (comment)

@dipeshmsft
Copy link
Member

Thanks @ThomasGoulet73, I took a look at this, and it fixes the issue I was talking about. I am going ahead with the merge. Once again, thanks for investigating this issue.

@dipeshmsft dipeshmsft merged commit 2ff7cad into dotnet:main Jan 28, 2025
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants