soundaranbu/Razor.Templating.Core

Project with RazorTemplating dont start after publish in IIS

MarcosxDeveloper opened this issue · 11 comments

Web Error: HTTP error 503
Exception: Cant Locate System.Runtime

Hi @MarcosxDeveloper, kindly let me know the following details
Package version: ?
.NET Version: ?

@MarcosxDeveloper , I've tried with Razor.Templating.Core 1.5.0 & 1.6.0-rc.2 with .NET Core 3.1 and ASP.NET Core Module installed in IIS. But I couldn't replicate the issue. If you can provide any sample project that works and one that doesn't work will be helpful to move forward with this issue.

hello @soundaranbu!

I used Razor.Templating.Core 1.6.0-rc.2 with .NET Core 5.0 and ASP.NET Core Module installed in IIS.

I think the problem is in the line of the razor project.

Since in the development environment using the sdk it works fine.

Ok then I'll try with .NET 5

It works with .NET 5 as well @MarcosxDeveloper
You can clone this repository & try this mvc project https://github.com/soundaranbu/RazorTemplating/tree/master/examples/Mvc/ExampleWebApp.Net5_0

thank you @soundaranbu,

I shared my error exception for more details about this issue.

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)    
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViewsCore(IServiceCollection services)   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViews(IServiceCollection services)    
   at sb.PPU.Web.Startup.ConfigureServices(IServiceCollection services) in C:\Users\margonzalez\Documents\Azure DevOps\ProUsuario App\sb.PPU.Web\Startup.cs:line 40
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo 
culture)
   at Microsoft.AspNetCore.Hosting.MethodInfoExtensions.InvokeWithoutWrappingExceptions(MethodInfo methodInfo, Object obj, Object[] parameters)
   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__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at sb.PPU.Web.Program.Main(String[] args) in C:\Users\margonzalez\Documents\Azure DevOps\ProUsuario App\sb.PPU.Web\Program.cs:line 12

It looks like the stack trace don't have any references to Razor.Templating.Core library.

If you can submit a sample project that has this issue, I'll be able to look at it. @MarcosxDeveloper

excuse me @soundaranbu

I found the problem in the project publish profile.

now the project is perfectly working.

another question

Can I add the razor views in an existing library project and not in a separate razor project?

I was trying and when running the project it did not find the views.

You can. But you need to target Microsoft.NET.Sdk.Razor SDK for your existing library.

thank you for all.

I am currently using clean architecture in my project

Sample:

MyProject.Web
-- MyProject.Infrastructure [.NET Library]
---- MyProject.Core [.NET Library]

but seeing that this package only works with razor class library i changed to:

MyProject.Web
-- MyProject.Infrastructure [.NET Library]
---- MyProject.Razor [Razor Library]
------ MyProject.Core [.NET Library]