Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Dnn 10.2.1 breaks 2sxc because of changes in DnnJsInclude

Open
#6,902 18 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
backend

Research direction

Start with DNN Platform/DotNetNuke.Web.Client/Controls/DnnJsInclude.cs, especially the constructors and the clientResourceController property cited in the issue. Reproduce the crash using the listed steps with DNN 10.2.0/10.2.1 and a 2sxc version up to 21.00.01, then trace how the controller is obtained. Done means registering JS dependencies no longer crashes IIS for those versions.

Written by the indexing model from the issue text.

Description

Status: New
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

Basically if 2sxc uses ClientDependency it crashes.
This started in 10.2.0 and got a fix in 10.2.1 but it not working properly.
The result is a full blown IIS crash, unhandled win32 exception

Image

Reason is that 2sxc creates a DnnJsInclude and adds it to the page. We will change our code to work around the problem, but anybody upgrading DNN with a current or older 2sxc will crash the entire IIS process - see https://github.com/2sic/2sxc/issues/3717.

Here's how our code works:

var include = new DnnJsInclude 
{
    ForceProvider = DnnProviderName(clientAsset.PosInPage), 
    Priority = clientAsset.Priority, 
    FilePath = clientAsset.Url, 
    AddTag = false
};

// direct dependency on ClientDependency.Core.dll (included in default DNN installation)
if (clientAsset.HtmlAttributes?.Count > 0)
{
    // not important for this issue
}
// THIS IS WHERE IT BLOWS
page.FindControl("ClientResourceIncludes")?.Controls.Add(include);

The problem is probably here:

https://github.com/dnnsoftware/Dnn.Platform/blob/ea2cc0373d4ee8d5c28805cf6901fbb4e57d88b6/DNN%20Platform/DotNetNuke.Web.Client/Controls/DnnJsInclude.cs#L22-L49

Basically an empty constructor was "added back" - which I guess was a great idea, but later on it expects a service which doesn't exist in the empty constructor scenario. My guess is that in certain cases, the empty constructor doesn't properly run this:

https://github.com/dnnsoftware/Dnn.Platform/blob/ea2cc0373d4ee8d5c28805cf6901fbb4e57d88b6/DNN%20Platform/DotNetNuke.Web.Client/Controls/DnnJsInclude.cs#L47-L53

I guess the problem is that this property

https://github.com/dnnsoftware/Dnn.Platform/blob/ea2cc0373d4ee8d5c28805cf6901fbb4e57d88b6/DNN%20Platform/DotNetNuke.Web.Client/Controls/DnnJsInclude.cs#L19

My guess is as follows

  1. I think that the compiler adds another empty constructor (just a guess) to web controls
  2. ...and that we're probably calling that, instead of the new one but I'm just guessing. If my guess is correct, the this(null) would not be called. Or there is a problem that the built-in webcontrol base constructor is not called. again, just guessing.

So again: we'll create a 2sxc 21.0x soon to work around this, as we were only using this API to work around something, which was later added to DNN. But anybody upgrading DNN without previously upgrading 2sxc will run into problems.

My guess for a fix would be something like:


private IClientResourceController clientResourceController => field ??= DependencyInjection.GetCurrentServiceProvider().GetRequiredService<IClientResourceController>();

...might fix the problem - @donker

Steps to reproduce?
  1. install any 2sxc up to v21.00.01 on the latest DNN.
  2. Add a normal app or content-module, which wants to register JS dependencies.
  3. See IIS crash.
Current Behavior

see above

Expected Behavior

No response

Relevant log output

Anything else?

No response

Affected Versions

10.2.0 (latest v10 release)

What browsers are you seeing the problem on?

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
C#
Stars
1.1k
Forks
791
Avg merge
2d 49m
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dnnsoftware/Dnn.Platform

All issues in dnnsoftware/Dnn.Platform

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.