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

Oqtane - Error compiling AppCode.dll #3505

Closed
enfJoao opened this issue Nov 14, 2024 · 20 comments
Closed

Oqtane - Error compiling AppCode.dll #3505

enfJoao opened this issue Nov 14, 2024 · 20 comments
Assignees

Comments

@enfJoao
Copy link

enfJoao commented Nov 14, 2024

I'm submitting a

[x] bug report

...about

[x] other / unknown

Current Behavior / Expected Behavior

Importing apps from DNN to test in Oqtane. Some work with no issues, other report this:

Error: System.Exception: Error: Can't compile 'AppCode.dll' in AppCode. Details are logged into insights. Bad IL format. The format of the file ' .... \App_Data\2sxc.bin\App-00006-AppCode-5c98a772de834cf2f6cbaba95a058d43347c40224e3ac673b0d60a04183c20b8.dll' is invalid. at ToSic.Sxc.Razor.RazorCompiler.FindViewAsync(ActionContext actionContext, String partialName, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorCompiler.CompileView(String partialName, Action1 configure, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorRenderer.RenderToStringAsync[TModel](String templatePath, TModel model, Action1 configure, IApp app, HotBuildSpec hotBuildSpec) at ToSic.Sxc.Razor.RazorEngine.RenderTask(RenderSpecs specs)

This is the content of the folder:
image

Instructions to Reproduce the Problem

Load any view (from specific apps with no significant differences).

Your environment

  • 2sxc version(s): 18.02.00
  • Oqtane: 5.2.4
  • Hosting platform: IIS
@iJungleboy
Copy link
Contributor

@tvatavuk any ideas?

Is there a chance that two compilers try to create the file at the same time, and refuse to overwrite a 0-byte file or something?

@enfJoao
Copy link
Author

enfJoao commented Nov 14, 2024

Deleted the files in the folder, restarted the server, same output. One app generates the files and the app runs, the other generates the errors.
image

image

@tvatavuk tvatavuk self-assigned this Nov 14, 2024
@enfJoao
Copy link
Author

enfJoao commented Nov 25, 2024

Any news on this fix?

I've been trying 2sxc on Oqtane for a couple months now, and evertime I got stalled by one or another error.

@iJungleboy
Copy link
Contributor

I believe @tvatavuk will look into this this week.

@jaruiz1961-ual
Copy link

I have had the same problem with oqtane 6.0 for .NET 9.0
Cheers

@tvatavuk
Copy link
Contributor

@enfJoao, thank you for reporting this issue.

It appears that the DLL is locked because multiple requests to the same app are attempting to compile it simultaneously (for example, if you have the same app added 10 times on the same page), which may be causing the compilation to fail.

First, I need to reproduce this issue on my computer to identify the cause and fix it. I've conducted several tests, but everything is working as expected on my end.

Could you please provide more details to help me investigate further? Ideally, if you have an Oqtane site that you can share with me, I could restore it on my system to see what's happening.

  • Are you using Windows Desktop or Windows Server? Which version?
  • Are you using the development version of Oqtane or the release version?
  • Do you have any antivirus software that might lock DLL files during creation?
  • What type of file storage are you using—local HDD, SSD, or a network drive?

Thank you!

@enfJoao
Copy link
Author

enfJoao commented Nov 27, 2024

Win 11 pro 24H2
Release version
Windows defender only, but the issue happens with it on or off.
Local M.2 (One partition for win, one for IIS sites).

There is only one app in the page.
This app is configured the exact same way that a couple others are. The others work fine.
The only difference is that this problematic one is a lot bigger in entity types and data.
This same app runs on DNN on the same server.
If I delete the dlls, the app will run once. As soon as I reload, the error will pop.

I cannot share the app since there is sensitive data on in.

@tvatavuk
Copy link
Contributor

@enfJoao Thank you for providing the additional information — it was very helpful in narrowing down the test cases as I worked to reproduce the issue in my development environment. I conducted tests with several large applications (1k+, 10k+ and 50k+ entities), and everything appeared to work as expected, so unfortunately, I was not successful in reproducing the issue on my setup.

image

However, based on details in your report, I have added some code to prevent the locking of App_Code*.dll during compilation in the Oqtane version. On my side, this change has already shown noticeable improvements in performance, which is a positive outcome. This fix is expected to be included in the next release.

If you're willing (and/or @jaruiz1961-ual), it would be great if you could test this on your Oqtane setup. I can provide you with today's build from the development branch: ToSic.Sxc.Oqtane.Install.18.4.0-fix3505.nupkg. Let me know if you'd like to try it!

@enfJoao
Copy link
Author

enfJoao commented Nov 29, 2024

@tvatavuk sure.

@tvatavuk
Copy link
Contributor

@tvatavuk sure.

Here is link on my OneDrive ToSic.Sxc.Oqtane.Install.18.4.0-fix3505.nupkg

@enfJoao
Copy link
Author

enfJoao commented Nov 29, 2024

I'm having issues installing modules, but I think I got it (ToSic.Sxc.Oqtane.Install.18.4.0-fix3505.log seems to point that way).
oqtane/oqtane.framework#4884

New error:
Error: System.Exception: Error: Can't compile 'AppCode.dll' in AppCode. Details are logged into insights. Image is too small. at ToSic.Sxc.Razor.RazorCompiler.FindViewAsync(ActionContext actionContext, String partialName, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorCompiler.CompileView(String partialName, Action1 configure, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorRenderer.RenderToStringAsync[TModel](String templatePath, TModel model, Action1 configure, IApp app, HotBuildSpec hotBuildSpec) at ToSic.Sxc.Razor.RazorEngine.RenderTask(RenderSpecs specs)

Also creates an empty dll.
Deleting the dll does not fix it (it just recreates the empty file again).
I'm trying to strip the app down to bare minimum to see if I can share it.

@enfJoao
Copy link
Author

enfJoao commented Nov 29, 2024

Ok... This was a lot faster than I expected.
As soon as I deleted the AppCode folder, the issue is gone.
To trigger this issue in any Oqtane 2sxc I just have to create an AppCode folder (even if empty) and add the line @using AppCode to the template (even if no actual .cs is called).

@tvatavuk
Copy link
Contributor

tvatavuk commented Dec 2, 2024

I'm having issues installing modules, but I think I got it (ToSic.Sxc.Oqtane.Install.18.4.0-fix3505.log seems to point that way). oqtane/oqtane.framework#4884

The issue you are encountering with module installation might be related to a OS limitation on IIS10 when running on desktop versions of Windows 10/11. This limitation stems from the capped number of concurrent network connections, which can cause uploads to freeze if the JavaScript responsible for splitting large uploads into smaller batches exceeds the connection limit. This problem does not occur on Windows Server, where the connection cap is higher.

Workaround
To bypass the upload issue, you can manually place the NuGet package into the /Packages folder of your Oqtane installation and then restart the application. This will trigger the module nuget installation process without requiring the web-based upload.

@tvatavuk
Copy link
Contributor

tvatavuk commented Dec 3, 2024

@enfJoao, could you please share your stripped-down app that demonstrates the issue? I'm still unable to reproduce it on my end.

You mentioned:

Ok... This was a lot faster than I expected. As soon as I deleted the AppCode folder, the issue is gone. To trigger this issue in any Oqtane 2sxc I just have to create an AppCode folder (even if empty) and add the line @using AppCode to the template (even if no actual .cs is called).

Based on this, it seems that the presence of an AppCode folder and the usage of @using AppCode in the template—even without any actual .cs files—triggers the issue. I did try to replicate this scenario to see if I can reproduce the problem. Here's what I've done:

Everything is working as expected, and I can't reproduce the issue you're experiencing.

image
image
image

Any additional details or a sample app would be greatly appreciated to help diagnose and resolve this issue.

@enfJoao
Copy link
Author

enfJoao commented Dec 3, 2024

Ok.

I tried three things:

  1. Moving the current database and files to a new server
  2. Removing IIS and configurations from the current server and reinstalling everything
  3. Creating a new install of Oqtane 6.0 in the current server after the IIS config reset

There are two important issues I tested: the file upload failures in Oqtane and the AppCode compile failure.
On 1 (same files, different server) and 3 (new 6.0 install on same server with new IIS config ) the file upload issues are gone and the AppCode issue is gone (mostly).
On 2 (same files, new IIS config) the issues persist.

So this have to be caused by a combination of IIS config and files / oqtane config. Either way I'm not going to pursuit this any more. Just going forward with the new 6.0 install.

BUT, I can still replicate the AppCode compile error with this condition:
Any code error in the AppCode/helper.cs causes an initial display of the error, and then the "Can't compile 'AppCode.dll' in AppCode" after a reload.
I migrate the test apps from DNN, so there are a lot of issues with framework => .net core (like the HttpCookie class and all cookie related fetch functions).

So this HAS TO be replicate the issue on your end:

@inherits Custom.Hybrid.RazorTyped
@using AppCode

<div @Kit.Toolbar.Default()>
    MyHelpers.Hello("World")
</div>
namespace AppCode
{
    public class MyHelpers {

        public static string Hello(string a) {
            return "Hello" + a;
        }
    }
}

To trigger the issue change
return "Hello" + a;
to
return "Hello" + ab;
or any other code error

The first load gets this:
Error: System.Exception: CS0103: The name 'ab' does not exist in the current context at ToSic.Sxc.Razor.RazorCompiler.FindViewAsync(ActionContext actionContext, String partialName, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorCompiler.CompileView(String partialName, Action1 configure, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorRenderer.RenderToStringAsync[TModel](String templatePath, TModel model, Action1 configure, IApp app, HotBuildSpec hotBuildSpec) at ToSic.Sxc.Razor.RazorEngine.RenderTask(RenderSpecs specs)

And after a reload:
Error: System.Exception: Error: Can't compile 'AppCode.dll' in AppCode. Details are logged into insights. Image is too small. at ToSic.Sxc.Razor.RazorCompiler.FindViewAsync(ActionContext actionContext, String partialName, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorCompiler.CompileView(String partialName, Action1 configure, IApp app, HotBuildSpec spec) at ToSic.Sxc.Razor.RazorRenderer.RenderToStringAsync[TModel](String templatePath, TModel model, Action1 configure, IApp app, HotBuildSpec hotBuildSpec) at ToSic.Sxc.Razor.RazorEngine.RenderTask(RenderSpecs specs)

The only thing that changed with the new server or new install in new IIS config is that the error now only triggers if there are codding errors on the helper (before is happened even with no helpers in the folder).

If you still cannot replicate this, please give me an e-mail address to send you the login info to a test install on my server.

@tvatavuk
Copy link
Contributor

tvatavuk commented Dec 3, 2024

Thank you for the detailed feedback—it has been very helpful in narrowing down the issue.

  • I was able to reproduce the problem, and as suspected, the AppCode.dll being generated with a file size of 0 is indeed unexpected.
  • This behavior is not helpful for developers using 2sxc in identifying and resolving issues.
  • The expected behavior should align more closely with DNN's handling of uncompiled C# code. Specifically:
    • If the code in AppCode contains errors, it should result in a meaningful error message indicating the issue, rather than generating a corrupted or empty AppCode.dll.
    • No AppCode.dll should be created at all in cases where the compilation fails.

image
image
image

Thank you again for the comprehensive test scenarios—it’s instrumental in replicating and resolving such issues!

tvatavuk added a commit that referenced this issue Dec 3, 2024
tvatavuk added a commit that referenced this issue Dec 3, 2024
@tvatavuk
Copy link
Contributor

tvatavuk commented Dec 3, 2024

Issue is fixed.
It is expected to be part of the next 2sxc release.

@jaruiz1961-ual
Copy link

Here it is the error in azure
https://ja-oqtane9.azurewebsites.net/accordion
If you want an account to install or uninstall and test it, let me know ... jaruiz@ual.es

@jaruiz1961-ual
Copy link

image

@iJungleboy
Copy link
Contributor

we should have a release out by this weekend

@github-project-automation github-project-automation bot moved this to Done in 2sxc 18 Dec 4, 2024
@iJungleboy iJungleboy moved this from Done to v18.05.00 in 2sxc 18 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: v18.05.00
Development

No branches or pull requests

4 participants