No effect with 'inject' when use FileSystem Project
See original GitHub issueSame with #211 , When I use FileSystem Project (UseFilesystemProject(projectPath)
), like this:
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject(projectPath)
.UseMemoryCachingProvider()
.Build();
services.AddRazorLight(() => engine);
and inject in tamplate like this:
@inject IConfiguration configuration
Finally, I got a NullReferenceException, what should I do ? Thanks~
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
When is it not appropriate to use the dependency injection ...
Basically, dependency injection makes some (usually but not always valid) assumptions about the nature of your objects. If those are wrong, ...
Read more >Criticism and disadvantages of dependency injection
So you might decide to inject the external service and the file system as interface dependencies, which will allow you to inject mocks...
Read more >Laravel dependency injection - bindings
I've noticed that when calling the exists method on the injected $filesystem object with a directory that does not exist, the condition ...
Read more >Make it easier to inject the FileSystem service [#3048126]
We have quite a few places where it is problematic to inject the file system service, due to either direct or indirect circular...
Read more >5 Reasons to Use Dependency Injection in Your Code
Because of the externally injected dependencies, developers can scale up the application without worrying about managing dependencies manually ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, @toddams I find this problem, in source code of method
AddRazorLight
:Method
AddEngineRenderCallBacks
be called when dotnet core injectsIRazorLightEngine
, but I don’t inject it and makeengine
as a prop to other class, and inject other class, like this:@Andrioden Maybe your problem is the same reason.
@smartlei24 Thanks for all your help explaining this problem.
So, I think there may be several red flags here.
One, that I didn’t notice before, is “
builder.
”. I think what builder is matters a lot here. Are you by any chance using Blazor - I found this via searching code snippets for “builder.Services”Two, why aren’t you simply doing the following:
and