We use Umbraco and have some custom pages where we inject our own services, a secondary database and so on. However, now when we removed code/a package from source code and try to deploy it all we see on our Azure deploy is this:
An error occurred while starting the application.
FileNotFoundException: Could not load file or assembly ‘SomeAssembly Version=SomeVersion, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified.
But the whole package is removed from source code. It should not be looked for anymore. The error should not be there since the package is no longer in use - AT ALL. It’s a custom package as well that no other package is referencing.
Deployed with “Remove additional files from server” from a clean solution and Zip deloy via Azure Devops + from local machine, multiple combinations. Restarted the application a million times. There seems to be no way to make Umbraco aware that this file is no longer available and should not be available and is not in use anymore.
Since there’s no UI/Admin to clear any internal caching - how do we even go about doing this? Why is old code running on the server when deploying new code for Umbraco?
Running version 13 and not gonna update to fix this issue at the moment. There should be a way to clear whatever is locking Umbraco from loading new files without having to upgrade to 15 for example.
Edit: Adding missing package one by one seems to generate an error for each of these packages. So, what is making it check for old code that is LITERALLY not running anywhere in the solution? To be absolutely clear - none of these packages are in use ANYWHERE in code anymore.
Just the obvious, but there is no longer a reference to the package in any project file? It works locally?
If you are certain its some kind of cache, you could change the tier from for instance p1v3 to p2v3 and back. Because azure actually moves the application, that has sometimes saved me from issues that I couldnt solve.
No, there are two very specific packages that are not used by another packages internally. I can guarantee that. And the packages are gone from the solution altogether. Deployed it tries to look for the package and shows that error but works in localhost connected to the same db / blob storage / cdn, etc. Adding those packages again makes the application run - question is why since there are no reference in any code to them. But I’ve experienced what I like to call ghost code on Azure from time to time so perhaps it’s just that. Azure function mostly, never on an App service. I’ll try to upgrade and downgrade later tonight and see if there’s any change.
@thedeuk Did you find a solution to this? I am experiencing the same issue in Azure (Web) App Service after removing a package (SimpleRedirects) from our solution.
Running the command: dotnet "Contoso.Web.dll"
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'ClosedXML, Version=0.95.4.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'ClosedXML, Version=0.95.4.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Umbraco.Cms.Core.Composing.ReferenceResolver.ResolveAssemblies()
at Umbraco.Cms.Core.Composing.FindAssembliesWithReferencesTo.Find()
at Umbraco.Cms.Core.Composing.DefaultUmbracoAssemblyProvider.get_Assemblies()
at Umbraco.Cms.Core.Composing.TypeFinder.GetAllAssemblies()
at Umbraco.Cms.Core.Composing.TypeFinder.GetFilteredAssemblies(IEnumerable`1 excludeFromResults, String[] exclusionFilter)
at Umbraco.Cms.Core.Composing.TypeFinder.get_AssembliesToScan()
at Umbraco.Cms.Core.Composing.TypeLoader.get_AssembliesToScan()
at Umbraco.Cms.Core.Composing.TypeLoader.<GetDiscoverableTypes>b__20_0()
at Umbraco.Cms.Core.Composing.TypeLoader.GetTypesInternalLocked(Type baseType, Type attributeType, Func`1 finder, String action, Boolean cache)
at Umbraco.Cms.Core.Composing.TypeLoader.GetTypesInternal(Type baseType, Type attributeType, Func`1 finder, String action, Boolean cache)
at Umbraco.Cms.Core.Composing.TypeLoader.GetDiscoverableTypes()
at Umbraco.Cms.Core.Composing.TypeLoader.GetTypes[T](Boolean cache, IEnumerable`1 specificAssemblies)
at Umbraco.Cms.Core.DependencyInjection.UmbracoBuilderExtensions.AddAllCoreCollectionBuilders(IUmbracoBuilder builder)
at Umbraco.Cms.Core.DependencyInjection.UmbracoBuilder.AddCoreServices()
at Umbraco.Cms.Core.DependencyInjection.UmbracoBuilder..ctor(IServiceCollection services, IConfiguration config, TypeLoader typeLoader, ILoggerFactory loggerFactory, IProfiler profiler, AppCaches appCaches)
at Umbraco.Extensions.UmbracoBuilderExtensions.AddUmbraco(IServiceCollection services, IWebHostEnvironment webHostEnvironment, IConfiguration config)
at Umbraco.Extensions.WebApplicationBuilderExtensions.CreateUmbracoBuilder(WebApplicationBuilder builder)
at Program.<Main>$(String[] args) in /home/runner/work/ContosoWebsite/ContosoWebsite/Contoso.Web/Program.cs:line 10
at Program.<Main>(String[] args)
/opt/startup/startup.sh: line 20: 1872 Aborted
I traced the dependency from SimpleRedirects > SimpleRedirects.Core > CsvHelper.Excel.Core > ClosedXML (specifically 0.95.4.0).
This package should not be used anywhere in the project at this point…
> dotnet nuget why Contoso.Web\Contoso.Web.csproj ClosedXML
Project 'Contoso.Web' does not have a dependency on 'ClosedXML'.
This is in the middle of an upgrade to Umbraco 17 / .NET 10 migration so potentially many things that can cause it but it seems your case was more isolated.
Sure enough, there was a SimpleRedirects.dll file still in the file system. I deleted the wwwroot folder where the .dll was located and the application started after redeploying.
What thedeuk observed was likely something else since he tried deploying with “Remove additional files from server” outside of a GitHub Action. I think this setting does something equivalent to my manual deletion.