Working on a massive CRM web app which uses a webforms site as the main site to host other modules using iframes. When the site is accessed, it loads all the assemblies, and currently facing a bottleneck with the number of dlls that can be loaded. There's around 1850 dlls, and if I add a new dll I get the following compilation error:

`Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1647: An expression is too long or complex to compile

Source Error:

[No relevant source lines]

Source File: Line: 0 Show Detailed Compiler Output:

________________________________________ Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0`

The detailed compiler output just shows the paths to all the assemblies. So current situation, if I want to add new assemblies I need to delete something else, or else I get this error.

I'm pretty sure the following line of code is responsible, but I could be wrong:

`var ourAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList().FindAll(a => a.FullName.Contains("SITE_NAME"));`

My guess was that the number of dlls is causing the variable holding the list of assemblies to overflow after a certain point. So I tried using two different variables to handle the assemblies instead of one.

`var allAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); var first1500Assemblies = allAssemblies.Where(a => a.FullName.Contains("SITE_NAME")).Take(1500).ToList(); var restOfAssemblies = allAssemblies.Where(a => a.FullName.Contains("SITE_NAME")).Skip(1500).ToList(); `

No success.

Also tried fiddling around with IIS file size limits. Adding dlls which don't contain "SITE_NAME" doesn't trigger the error.

Context: This is part of a giant codebase, so I'm looking for solutions that don't require big changes. I think some kind of dynamic loading strategy instead of loading all the assemblies at once at startup would be a better approach, so I'm currently looking into ways of implementing that but couldn't find a fix yet.

The full method that holds the above code:

        public static SystemVersionInfo GetSystemVersionInfo(out MessageSet msg)
    {
        msg = null;
        SystemVersionInfo toReturn = new SystemVersionInfo();
        try
        {
            var ourAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList().FindAll(a => a.FullName.Contains("SITE_NAME"));

            List<LibInfo> SITEAssembliesInfo = new List<LibInfo>();
            ourAssemblies.ForEach(a =>
            {
                SITEAssembliesInfo.Add(new LibInfo() { name = a.GetName().Name, version = a.GetName().Version.ToString(), BuildDate = a.GetLinkerTime() });

            });
            toReturn.SITELibs = SITEAssembliesInfo.OrderBy(l => l.name).ToList();

            List<LibInfo> otherAssembliesInfo = new List<LibInfo>();
            var otherAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList().FindAll(a => !a.FullName.Contains("SITE_NAME"));
            otherAssemblies.ForEach(a =>
            {
                otherAssembliesInfo.Add(new LibInfo() { name = a.GetName().Name, version = a.GetName().Version.ToString() });

            });
            toReturn.ThirdPartyLibs = otherAssembliesInfo.OrderBy(l => l.name).ToList();
        }
        catch (Exception ex)
        {
            msg = MessageCreate.CreateErrorMessage(0, ex, "GetSystemVersionInfo", "SITE_NAME.THIS_APP.WEB.dll");
        }

        return toReturn;

    }
0

There are 0 best solutions below