FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Getting error loading file or assembly using latest FluentEmail 2.5.1

Open leniel opened this issue 6 years ago • 6 comments

Hello,

I have the following packages installed:

  <package id="FluentEmail.Core" version="2.5.1" targetFramework="net472" />
  <package id="FluentEmail.Razor" version="2.5.1" targetFramework="net472" />
  <package id="FluentEmail.Smtp" version="2.5.2" targetFramework="net472" />

RazorLight is version alpha-3:

<package id="RazorLight" version="2.0.0-alpha3" targetFramework="net472" />

When trying to send an e-mail with a template like this one:

public async Task SendEmail()
{
    var template = "Dear @Model.Name, You are totally @Model.Compliment.";

    email.To(configuration["emailTo"])
        .Subject("Test e-mail")
        //.Body("Test");
        .UsingTemplate(template, new { Name = "Leniel Maccaferri", Compliment = "Awesome" });

    await email.SendAsync();
}

it fails with:

screen shot 2018-10-19 at 15 48 14

leniel avatar Oct 19 '18 18:10 leniel

Well... I just took a look at the project's bin folder and System.Runtime is not there even though It has Copy Local = true...

What could be the problem?

leniel avatar Oct 19 '18 19:10 leniel

This should be fixed by Razorlight's 2.0.0-beta1. I've pushed version FluentEmail.Razor 2.5.2 to include it. Can you please try that and let me know if it solves the problem?

bjcull avatar Oct 20 '18 06:10 bjcull

Hi Ben,

Just installed the new NuGet package... this time the installation went well. However, when running the code I get an exception {"Object reference not set to an instance of an object."} related to RazorLight.

FYI: I'm trying this using a .NET Framework 4.7.2 Console Application.

Source RazorLight

TargetSite {System.Collections.Generic.IReadOnlyList`1[Microsoft.CodeAnalysis.MetadataReference] Resolve(Microsoft.Extensions.DependencyModel.DependencyContext)}

StackTrace

at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext)\r\n at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly)\r\n at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()\r\n at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions()\r\n at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText)\r\n at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)\r\n at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)\r\n at RazorLight.Compilation.RoslynCompilationService.CompileAsync(IGeneratedRazorTemplate razorTemplate)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at RazorLight.Compilation.TemplateFactoryProvider.<CompileAsync>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at RazorLight.Compilation.TemplateFactoryProvider.<CreateFactoryAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at RazorLight.RazorLightEngine.<CompileTemplateAsync>d__14.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at RazorLight.RazorLightEngine.<CompileRenderAsync>d__11.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at FluentEmail.Razor.RazorRenderer.<ParseAsync>d__0`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at FluentEmail.Razor.RazorRenderer.FluentEmail.Core.Interfaces.ITemplateRenderer.Parse[T](String template, T model, Boolean isHtml)\r\n at FluentEmail.Core.Email.UsingTemplate[T](String template, T model, Boolean isHtml)\r\n at MyCompany.MyProject.Mailer.<SendEmail>d__4.MoveNext() in C:\MyCompany\Projects\MyCompany.MyProject\Mailer.cs:line 27\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at MyCompany.MyProject.DailyMail.<Run>d__3.MoveNext() in C:\MyCompany\Projects\MyCompany.MyProject\DailyMail.cs:line 27\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at MyCompany.MyProject.Program.<Main>d__1.MoveNext() in C:\MyCompany\Projects\MyCompany.MyProject\Program.cs:line 33

leniel avatar Oct 20 '18 15:10 leniel

@leniel I have the same issue. This bug was also noted on the RazorLight tracker; it was Closed pending a fix in the next release.

Morgma avatar Nov 20 '18 23:11 Morgma

Is there any temporary solution?

Almeonamy avatar Dec 21 '18 13:12 Almeonamy

Fixed by #186

bjcull avatar Jan 04 '20 10:01 bjcull