-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Hi,
Since the most recent update of runner images 17/03 my web apps built with these images stopped launching with exception:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Could not load file or assembly 'Typezor.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified. Could not load file or assembly 'Typezor.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified. at System.Reflection.RuntimeModule.GetDefinedTypes() at
System.Reflection.RuntimeAssembly.get_DefinedTypes() at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.get_Types() at
Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature) at
Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at
Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes() at
Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors() at
Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection() at
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize() at
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken() at
Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer,
TState state) at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer) at
Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe() at
Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource..ctor(ControllerActionEndpointDataSourceIdProvider
dataSourceIdProvider, IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory, OrderedEndpointsSequenceProvider
orderSequence) at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder
endpoints) at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapControllers(IEndpointRouteBuilder endpoints) at
Program.<Main>
Version Used:
.NET 10
ASP.NET Core ( tried any version from 10.0.2 to 10.0.5 )
Steps to Reproduce:
- Create a basic web app with dependency to the nugets:
<PackageReference Include="Typezor.SourceGenerator" Version="0.3.14" PrivateAssets="analyzer" />
<PackageReference Include="Typezor.Runtime" Version="0.3.14" PrivateAssets="all" />
<PackageReference Include="Typezor.CodeModel" Version="0.3.14" PrivateAssets="all" />
These are source generators that use cshtml files to generate code.
2. Include a basic cshtml that uses this source generator, like this:
@using System
@using System.IO
@using System.Linq
@using Typezor.CodeModel
@using File = System.IO.File
@inherits Typezor.TemplateBase<Typezor.CodeModel.File>
@{
#region Model Classes
}
/****************************************************************************
Generated by _models.cshtml - please don't make any changes in this file
****************************************************************************/
@{
@:declare namespace models {
@:
@:// #region Classes
@:
foreach (var model in Model.Classes.Where(IsModelClass).OrderBy(c => c.FullName))
{
@: /** Generated from @(model.FullName) **/
@: export interface @(model.Name)@(GenericTypes(model))@(model.BaseClass != null ? $" extends {model.BaseClass.Name}" : "") {
}
@:
@:// #endregion Classes
@:
Output.SaveAs(Path.Combine(Path.GetDirectoryName(TemplatePath), $"const.{model.Name}.ts"));
}
#endregion Model Classes
}
- Reference the file in csproj like this:
<ItemGroup>
<None Remove="ClientApp\src\models\_models.cshtml" />
<RazorGenerate Remove="ClientApp\src\models\_models.cshtml" />
<Content Remove="ClientApp\src\models\_models.cshtml" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="ClientApp\src\models\_models.cshtml" Typezor="true" />
</ItemGroup>
- Build the web site using the most recent runner images (windows-2022 or windows-2025-vs2026)
- Publish to an Azure WebApp
Expected Behavior:
The web app should run, no Typezor libraries should be included or referenced by runtime code ( they are just source generator libraries, not for runtime )
Actual Behavior:
The site doesn't run throwing exception:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Could not load file or assembly 'Typezor.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
It's somehow thinking that there is this library to scan for Controller types when this dll was excluded from the build output