You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a Blazor app and want to store components in a separate class library.
I works on .NET Core 3.0 preview 2 (except the static assets are not injected #6349),
but when I try to use @inject to inject some services entire page hangs.
The same component works and gets the service injects if I move it back to the root project.
To Reproduce
Steps to reproduce the behavior:
Install latest Blazor templates via dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19075-0444
Create a Razor components dotnet new razorcomponents / a Blazor app dotnet new blazor
Create an .NET Standard class library containing a class called SomeService
3.1 Inject a service in Startup.ConfigureServices method using .AddTransient<SomeService>()
Create a component with @inject SomeService someService tag
Try to run the application - it works
Create a new Razor Components class library dotnet new blazorlib -o MyComponentLib1
6.1 Fix namespaces and versions of the dependencies on the newly created project
Move previously created component into the newly created Razor Components class library
7.1 Fix the namespaces and using statements
Try to use the component on a page, it will hang the browser
Expected behavior
Components defined in separate Razor Components class libraries must be able to use dependency injection
The text was updated successfully, but these errors were encountered:
Eilon
added
the
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
label
Feb 19, 2019
For some reason in my project service injection does not work, unless I move the component from xxx.Shared.Components into xxs.App project, but that's not an ASP.NET Core / Razor Components / Blazor problem. I'm closing this issue.
OK, while describing the steps to reproduce the issue and then while building the sample repo I have oversimplified the service implementation I was having problem with.
Actually I had a service expecting another service to be injected for object->JSON serialization. My current implementation of the latter was relying on Json.NET (aka Newtonsoft.Json) which has known issue with Blazor or better with Blazor's linker.
After appending these rows to my Linker.xml
<linker>
...
<assemblyfullname="System.Core">
<!-- This is required by Json.NET and any expression.Compile caller -->
<typefullname="System.Linq.Expressions*" />
</assembly>
...
</linker>
ghost
locked as resolved and limited conversation to collaborators
Dec 3, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates
Describe the bug
I'm building a Blazor app and want to store components in a separate class library.
I works on .NET Core 3.0 preview 2 (except the static assets are not injected #6349),
but when I try to use
@inject
to inject some services entire page hangs.The same component works and gets the service injects if I move it back to the root project.
To Reproduce
Steps to reproduce the behavior:
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19075-0444
dotnet new razorcomponents
/ a Blazor appdotnet new blazor
SomeService
3.1 Inject a service in
Startup.ConfigureServices
method using.AddTransient<SomeService>()
@inject SomeService someService
tagdotnet new blazorlib -o MyComponentLib1
6.1 Fix namespaces and versions of the dependencies on the newly created project
7.1 Fix the namespaces and using statements
Expected behavior
Components defined in separate Razor Components class libraries must be able to use dependency injection
The text was updated successfully, but these errors were encountered: