diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs index 92b2925a21b0ae..ef0035d12a7e2d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -147,7 +147,11 @@ private static void AddDependenciesDueToCustomAttributes(ref DependencyList depe && InlineableStringsResourceNode.IsInlineableStringsResource(module, resName + ".resources")) { dependencies ??= new DependencyList(); - dependencies.Add(factory.InlineableStringResource(module), "EventSource used resource"); + var accessorMethod = module.GetType( + InlineableStringsResourceNode.ResourceAccessorTypeNamespace, + InlineableStringsResourceNode.ResourceAccessorTypeName) + .GetMethod(InlineableStringsResourceNode.ResourceAccessorGetStringMethodName, null); + dependencies.Add(factory.ReflectedMethod(accessorMethod), "EventSource used resource"); } } }