Problem adding own class library to Umbraco 11 install
Hi, I have spent all day on this and I am getting nowhere. Another dev set up an Umbraco v11.4.0 site out of the box to take over from an old site, all working fine.
However the old site had a small amount of custom functionality using custom services, which needs another DLL. This is what I have been struggling with, and I have just found out it doesn't need to have any of the custom stuff to not work. Minimal case to reproduce is:
Create a new .NET 7 class library to do this.
Added a NuGet reference to Umbraco 11.4.0.
Build.
Deploy to web server.
Umbraco fails to start with the following error:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'MyClassLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'MyClassLibrary, Version=1.0.0.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.<>c__DisplayClass21_0`1.<GetTypes>b__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.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, IHostingEnvironment hostingEnvironment)
at Umbraco.Extensions.UmbracoBuilderExtensions.AddUmbraco(IServiceCollection services, IWebHostEnvironment webHostEnvironment, IConfiguration config)
at my_umbraco_v11.Startup.ConfigureServices(IServiceCollection services) in C:\Temp\Projects\my_umbraco_v11\my_umbraco_v11\Startup.cs:line 32
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass14_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Umbraco.Cms.Web.Common.Hosting.UmbracoHostBuilderDecorator.Build()
at my_umbraco_v11.Program.Main(String[] args) in C:\Temp\Projects\my_umbraco_v11\my_umbraco_v11\Program.cs:line 6
I can't see any dependencies which might be the problem; the site works fine without this and immediately fails when it's put in with all the other DLLs, so clearly it's finding it in some way to then fail when it can't find it.
Permissions all seem correct - all DLLs have the same RX access for the app pool.
Found this appsettings change on another thread but that doesn't help:
Before I got down to the minimal case, I had another common library in there which gave the same error - this common library works perfectly on an another site, however, on that one, the Umbraco install has been built with it as a reference, not simply added to the assemblies folder.
Just deploying via FTP; so build in VS then upload the DLLs to the web server.
I solved my immediate problem for this site by just regenerating the templates and rebuilding the main assembly with my custom functionality as a reference which worked but I'd still like to be able to just add side-by-side functionality by just uploading assemblies without linking!
Problem adding own class library to Umbraco 11 install
Hi, I have spent all day on this and I am getting nowhere. Another dev set up an Umbraco v11.4.0 site out of the box to take over from an old site, all working fine.
However the old site had a small amount of custom functionality using custom services, which needs another DLL. This is what I have been struggling with, and I have just found out it doesn't need to have any of the custom stuff to not work. Minimal case to reproduce is:
Umbraco fails to start with the following error:
I can't see any dependencies which might be the problem; the site works fine without this and immediately fails when it's put in with all the other DLLs, so clearly it's finding it in some way to then fail when it can't find it.
Permissions all seem correct - all DLLs have the same
RX
access for the app pool.Found this appsettings change on another thread but that doesn't help:
...and now I've run out of ideas. Help!
Before I got down to the minimal case, I had another common library in there which gave the same error - this common library works perfectly on an another site, however, on that one, the Umbraco install has been built with it as a reference, not simply added to the assemblies folder.
Hi Rob,
How are you deploying to the web server (FTP, Publish etc.)
If you use the Publish tool, then you might want to check the .csproj file, to see if all files are included in build and publish.
I have fallen for this trap before, and this is normaly what does it.
Just deploying via FTP; so build in VS then upload the DLLs to the web server.
I solved my immediate problem for this site by just regenerating the templates and rebuilding the main assembly with my custom functionality as a reference which worked but I'd still like to be able to just add side-by-side functionality by just uploading assemblies without linking!
is working on a reply...