Build error - ArgumentNullException

Hi,

I’m getting this error during the build. The app runs ok, but some pages won’t render in the designer?

Error during application startup: System.ArgumentNullException: Value cannot be null. (Parameter 'implementationInstance')
at System.ArgumentNullException.Throw(String paramName)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton[TService](IServiceCollection services, TService implementationInstance)
at RadzenProgram.Configure(IServiceCollection services, IConfiguration configuration)
at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)

I’ve tried using the preprocessor to exclude certain bits of Program.cs, notably anything recently changed, but I can’t find anything?

Cheers

Reg

Hi @SolutionJ,

Check the dependencies of some of the pages that fail to render (the injected services). There is a service which accesses something in its constructor that is null in design time. You can apply the preprocessor directives there to avoid the access.

Good morning @korchev. I will work with your suggestion, but would it be possible in future for error messages arising during startup to provide more information about where they arose?

Hi @SolutionJ,

We would like to but it isn't possible. The exception you see is the exception that arises and we cannot tell more from it.

Oh. I thought it was your own software that fails. And it’s not possible to have any tracking either, so that we could see what progress the program had made before keeling over?

Unfortunately no, we can't do much more. The exception only shows that some AddSingleton method fails with ArgumentNullException.

I see. Does ‘Singleton’ refer to the way I’ve scoped the service in my app?

Yes, this is the only clue that I see. The service seems to be registered via AddSingleton.

Ok, that’s very helpful actually.

Thanks for your help with this, much obliged…