question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quickstart sample throws exception with 4.7.2

See original GitHub issue

Describe the bug A basic sample following the Quickstart throws the following exception on Build(): System.TypeLoadException: Method 'GetItem' in type 'NullRazorProjectFileSystem' from assembly 'RazorLight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. thrown at RazorLight.DefaultRazorEngine.get_Instance()

To Reproduce Steps to reproduce the behavior:

  • Create new project for console app using 4.7.2
  • Add code based on quickstart in main
namespace RazorLightTest
{
    using System;
    using System.Globalization;
    using System.Threading.Tasks;

    using RazorLight;

    public class Program
    {
        static async Task Main(string[] args)
        {
            CultureInfo.CurrentUICulture = new CultureInfo("en-us");

            var engine = new RazorLightEngineBuilder()
                .UseEmbeddedResourcesProject(typeof(Program))
                .UseMemoryCachingProvider()
                .Build();

            var template = "Hello, @Model.Name. Welcome to RazorLight repository";
            var model = new ViewModel { Name = "John Doe" };

            var result = await engine.CompileRenderStringAsync("templateKey", template, model);
            Console.WriteLine(result);
        }

        public class ViewModel
        {
            public string Name { get; set; }
        }
    }
}
  • Add RazorLight via “Manage NuGet packages…”
  • Update all NuGet packages to latest version (make sure to uncheck “Include prelease”)
  • Compile & Run

Expected behavior The application runs without problems and prints “Hello, John Doe. Welcome to RazorLight repository” to the console.

Information (please complete the following information):

  • Windows 10
  • .Net Framework 4.7.2
  • 2.0.0-beta9
  • package from NuGet
  • Visual Studio Enterprise 2019

Additional context The best solution right now if of course not to update the NuGet packages but stick to the original versions. The downside is that depending on the context this could cause NuGet to show packages to consolidate.

So if the code does not work with the more recent versions I wonder if there is a way to restrict the versions e.g. setting a maximum version of ❤️.0 on the dependency in the package for .NET Standard

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jzabroskicommented, Jul 2, 2021

Yes, if people are using packages.config, they are likely to have issues consuming .NET Core libraries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Console Application example not functional for .NET ...
Expected to see the output written to the console. What is the actual behavior? Exception is thrown: Method not found: 'OpenTelemetry.Trace.
Read more >
Displaying a Custom Error Page (C#)
The classes in the .NET Framework signal an error by throwing an exception. For example, calling a SqlConnection object's Open method ...
Read more >
What's new in .NET Framework
See what's new in various versions of .NET Framework. Read a summary of key new features and improvements in each version.
Read more >
Throwing Exceptions
"throw asynchronously", i.e. return a failed task with the exception. The former is supported by the Throws method described above, in the same...
Read more >
Usage of throws command in java
For Checked exceptions (happen at compile-time), we use 'throw' keyword and for Unchecked (Run-time), we use try() catch(). Example: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found