RazorLight icon indicating copy to clipboard operation
RazorLight copied to clipboard

Failed to compile generated razor view. See CompilationErrors for detailed information

Open williamwmd opened this issue 9 years ago • 6 comments

Hello, I'm trying to use a non-anonymous object and am getting the following error:

Failed to compile generated razor view. See CompilationErrors for detailed information

    public class TestModel
    {
        public string Name { get; set; }
    }
    var model = new TestModel()
    {
        Name = "John Doe"
    };
    var engine = EngineFactory.CreatePhysical(@"D:\");
    string result = engine.ParseString("Hello @Model.Name ", model, model.GetType());


williamwmd avatar Feb 15 '17 12:02 williamwmd

Hi

Try to execute this code in debug mode and look on CompilationErrors of an exception. It must provide you with a detailed information

toddams avatar Feb 15 '17 12:02 toddams

CompilationErrors:

The type or namespace name 'TestModel' could not be found (are you missing a using directive or an assembly reference?)

williamwmd avatar Feb 15 '17 12:02 williamwmd

Same error happens when you do not specify a model type? I mean without model.GetType()?

Another question: model is declared at the same assembly where you use RazorLight?

toddams avatar Feb 15 '17 12:02 toddams

Yes for their 2 questions. I'm using: "RazorLight": "1.0.0-rc1",

williamwmd avatar Feb 15 '17 12:02 williamwmd

Seem to be a bug, thank you for the report

toddams avatar Feb 15 '17 12:02 toddams

Fixed

toddams avatar Feb 19 '17 13:02 toddams