Skip to content

[Bug]: AmbiguousMatchException in ClientResourceSettings.GetPortalSettingThroughReflection due to unsafe Reflection call #6909

@thienvc

Description

@thienvc

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Description I am encountering a System.Reflection.AmbiguousMatchException in the error logs when running DNN Platform (version 10.2.1).

The error occurs within DotNetNuke.Web.Client.ClientResourceSettings.GetPortalSettingThroughReflection. After analyzing the source code, I believe the issue is caused by using Type.GetMethod(string name) without specifying the parameter types. Since PortalController has multiple overloads for GetPortalSettings (or similar methods), the reflection call fails because it finds an ambiguous match.

Steps to reproduce?

  1. Run a DNN Platform instance (v10.2.1).
  2. Check the Log4net files in Portals/_default/Logs.
  3. Observe the recurring AmbiguousMatchException.

Current Behavior

WARN DotNetNuke.Web.Client.ClientResourceSettings - Failed to Get Portal Setting Through Reflection
System.Reflection.AmbiguousMatchException: Ambiguous match found.
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at DotNetNuke.Web.Client.ClientResourceSettings.GetPortalSettingThroughReflection(Nullable`1 portalId, String settingKey)

Root Cause Analysis In DotNetNuke.Web.Client/ClientResourceSettings.cs, the method GetPortalSettingThroughReflection attempts to retrieve the method via Reflection using only the method name:

Expected Behavior

No response

Relevant log output

2026-01-13 20:46:47,527 [Latitude5520][D:2][Thread:6][INFO] DotNetNuke.Common.Initialize - Application Initialized
2026-01-13 20:46:48,192 [Latitude5520][D:2][Thread:6][WARN] DotNetNuke.Web.Client.ClientResourceSettings - Failed to Get Portal Setting Through Reflection
System.Reflection.AmbiguousMatchException: Ambiguous match found.
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at DotNetNuke.Web.Client.ClientResourceSettings.GetPortalSettingThroughReflection(Nullable`1 portalId, String settingKey)
2026-01-13 20:46:48,213 [Latitude5520][D:2][Thread:6][WARN] DotNetNuke.Web.Client.ClientResourceSettings - Failed to Get Portal Setting Through Reflection
System.Reflection.AmbiguousMatchException: Ambiguous match found.
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at DotNetNuke.Web.Client.ClientResourceSettings.GetPortalSettingThroughReflection(Nullable`1 portalId, String settingKey)

Anything else?

Root Cause Analysis In DotNetNuke.Web.Client/ClientResourceSettings.cs, the method GetPortalSettingThroughReflection attempts to retrieve the method via Reflection using only the method name:

// Current implementation (unsafe):
var method = PortalControllerType.GetMethod("GetPortalSettings", BindingFlags.Public | BindingFlags.Instance);

Because PortalController may contain multiple overloads for GetPortalSettings (e.g., one taking int portalId, another taking int portalId, string cultureCode, etc.), GetMethod cannot decide which one to return, throwing an AmbiguousMatchException.

Proposed Solution The reflection call should be made specific by providing the parameter types to ensure the correct overload is selected.

Recommended Fix:
Explicitly specify that we are looking for the overload taking 'int' as a parameter.

var method = PortalControllerType.GetMethod(
    "GetPortalSettings", 
    BindingFlags.Public | BindingFlags.Instance, 
    null, 
    new Type[] { typeof(int) }, 
    null
);

(Or match the specific signature required for the Invoke call).

Affected Versions

10.2.0 (latest v10 release)

What browsers are you seeing the problem on?

Chrome

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions