Razorlight.compilation исключение: не удалось снять шаблон сгенерированного бритвыC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Razorlight.compilation исключение: не удалось снять шаблон сгенерированного бритвы

Сообщение Anonymous »

Я создаю приложение для обслуживания .net 5, которое смотрит несколько других приложений и отправляет электронную почту при необходимости. Я использую FluenTemail для отправки этих электронных писем, и все работает нормально, пока я не развернут приложение.

Код: Выделить всё

RazorLight.Compilation.TemplateCompilationException: Failed to compile generated Razor template:
- (3:35) The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (3:10) The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (35:37) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (38:66) 'GeneratedTemplate.ExecuteAsync()': return type must be 'Task' to match overridden member 'TemplatePageBase.ExecuteAsync()'
- (38:66) The type 'Task' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (40:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (41:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (42:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (43:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (53:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (69:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (84:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (44:19) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (92:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (47:20) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (100:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (50:20) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (108:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (53:19) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (116:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (124:12) The type 'Object' is defined in an assembly that is not referenced.  You must add a reference to assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
See CompilationErrors for detailed information
at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)
at RazorLight.Compilation.RazorTemplateCompiler.CompileAndEmit(RazorLightProjectItem projectItem)
at RazorLight.Compilation.RazorTemplateCompiler.OnCacheMissAsync(String templateKey)
--- End of stack trace from previous location ---
at RazorLight.EngineHandler.CompileTemplateAsync(String key)
at RazorLight.EngineHandler.CompileRenderAsync[T](String key, T model, ExpandoObject viewBag)
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at FluentEmail.Razor.RazorRenderer.ParseAsync[T](String template, T model, Boolean isHtml)
at FluentEmail.Razor.RazorRenderer.FluentEmail.Core.Interfaces.ITemplateRenderer.Parse[T](String template, T model, Boolean isHtml)
at FluentEmail.Core.Email.UsingTemplateFromFile[T](String filename, T model, Boolean isHtml)
at WatchDog.Services.NotificationService.SendEmailAsync[TModel](String subject, String fileName, TModel model) in C:\Users\SomeOne\source\repos\WatchDog\WatchDog\Services\NotificationService.cs:line 41
< /code>
Моя настройка выглядит следующим образом: < /p>



 < /th>
 < /th>
< /tr>

 < /th> < /br /> < /tr> /> 

  
 






Views Folder


< /table> < /div>
Я добавил папку Views и обратите внимание, что это проект .net 5 Worker Service < /code> (если это важно вместо того, чтобы какой-то веб-проект). < /p>
 





Внутри конфигурации, я добавил Razorrenderer 
as:

Код: Выделить всё

//Set email service using FluentEmail
services.AddFluentEmail("appname@domain.com")
.AddRazorRenderer(@$"{Directory.GetCurrentDirectory()}/Views/")
.AddSmtpSender("smtp.somesmtp.com", 25)
.AddSmtpSender(new System.Net.Mail.SmtpClient() { });
< /code>
 


nhtificationservice.cs файл: < /th>
< /tr>
< /thead>
< /table> < /div>

< /thead>
< /table> < /div>

< /thead>
< /table> < /div>private async Task SendEmailAsync(string subject, TModel model)
{
try
{
using (var scope = _serviceProvider.CreateScope())
{
var email = await scope.ServiceProvider.GetRequiredService()
.To(string.Join(";", _emailRecipients))
.Subject(subject)
.UsingTemplateFromFile("./Views/Emails/SomeReport.cshtml", model)
.SendAsync();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to send email. Check exception for more information.");
}
}
< /code>
 


th> somereport.cshtml: < /th>
< /tr>
< /thead>
< /table> < /div>
   SomeReport.cshtml
находится внутри представлений \ emails \ somereport.cshtml , что выглядит следующим образом:

Код: Выделить всё

@using System.Collections.Generic;
@using WatchDog.Models;

@model IEnumerable
@{
Layout = "./Shared/_Layout.cshtml";
}

@* Work with the Model here...  *@
< /code>
 


th>_layout.cshtml Файл: < /th>
< /tr>
< /thead>
< /table> < /div>
  _Layout.cshtml
находится внутри представлений \ shared \ _layout.cshtml , что выглядит так:

Код: Выделить всё

@* Some common layout styles here *@
@RenderBody()
< /code>
 


th> watchdog.csproj file: < /th>
< /tr>
< /thead>
< /table> < /div>
  Reservecompilationcontext 
и консервисная ропилирование :

Код: Выделить всё

net5.0
true
true

Я смотрел повсюду и до сих пор не нашел решения.


Подробнее здесь: https://stackoverflow.com/questions/685 ... r-template
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Исключение RazorLight.Compilation: не удалось скомпилировать созданный шаблон Razor.
    Anonymous » » в форуме C#
    0 Ответы
    26 Просмотры
    Последнее сообщение Anonymous
  • Невозможно снять шаблон нижней колонтитула в шаблон нижнего колонтитула, используя доступные коды
    Anonymous » » в форуме CSS
    0 Ответы
    31 Просмотры
    Последнее сообщение Anonymous
  • ОШИБКА на СЕРВЕРЕ: jsp.error.compilation.dependent
    Гость » » в форуме JAVA
    0 Ответы
    19 Просмотры
    Последнее сообщение Гость
  • Заблокирован с помощью Android Studio Compilation. Manifestmerger2 $ MergeFailureExcept
    Anonymous » » в форуме Android
    0 Ответы
    6 Просмотры
    Последнее сообщение Anonymous
  • Используя Flutter, я получаю ошибку Daemon Permon Compilation: NULL
    Anonymous » » в форуме Android
    0 Ответы
    1 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C#»