Web assembly blazor dependency injection guide?

hi guys,

is there a guide available for web assembly blazor DI in Radzen?

what i'm trying to do is register a service which receives a JSON string and then forwards that to a service bus queue.

the code for sending to service bus, etc. is already in use, i know that works, but i'm having issues with the DI.

i think i'm missing one or two things, but cannot spot them

soo far i have

  1. created the service

  2. created an interface for that service

  3. in server.startup.custom.cs i have registered a singleton of the service

  4. i'm then trying to inject the service into a controller

  5. so at the 'onAfterxxxxxxCreated' event, i send the payload to the injected service

the error i'm getting is 'Object not set to instance of object'

this indicates to me the injection isn't working as expected.

any pointers as to what's missing?

I'm afraid that without debugging we cannot help much. If you have active Radzen subscription feel free to send us an example application demonstrating your case at info@radzen.com. If the project is too big you can use sharing service like Google Drive.

1 Like

The [Inject] attribute works only for Blazor components. To inject a service in a controller you should use a constructor parameter.

1 Like

okay so i'm trying this;

and it looks like it really doesn't like it

The exception message tells it all.