object reference not set to an instance of an object
Hi Tim
i'm sorry for late i post you this error before but i found the problem but i cannot solved
this code below is the reason when register dependencies
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
builder.RegisterType<Ta2healDbContext>().As<IUnitOfWork>().InstancePerReques();
builder.RegisterType<SubjectService>().As<ISubjectService>().InstancePerLifetimeScope();
builder.RegisterType<SectionService>().As<ISectionService>().InstancePerLifetimeScope();
builder.RegisterType<LessonService>().As<ILessonService>().InstancePerLifetimeScope();
// Set the dependency resolver to be Autofac.
var container = builder.Build();
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
and this when i stop some code of register dependencies
it's work when i do this into register dependencies code
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
builder.RegisterType<Ta2healDbContext>().As<IUnitOfWork>().InstancePerRequest();
builder.RegisterType<SubjectService>().As<ISubjectService>().InstancePerLifetimeScope();
builder.RegisterType<SectionService>().As<ISectionService>().InstancePerLifetimeScope();
builder.RegisterType<LessonService>().As<ILessonService>().InstancePerLifetimeScope();
// Set the dependency resolver to be Autofac.
//var container = builder.Build();
//var resolver = new AutofacWebApiDependencyResolver(container);
//GlobalConfiguration.Configuration.DependencyResolver = resolver;
//DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
but code that i stopped make some problem to me
so i ask you if you have any idea what can i do to solve this problem?
Ok seems this is due to autofac, you'll need to registed the UI-O-Matic tree controller, for details check the known issues doc, btw you'll need to do this for every third party tree
//register all controllers found in this assembly
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
//add custom class to the container as Transient instance
builder.RegisterType<Ta2healDbContext>().As<IUnitOfWork>().InstancePerRequest();
builder.RegisterType<SubjectService>().As<ISubjectService>().InstancePerLifetimeScope();
builder.RegisterType<SectionService>().As<ISectionService>().InstancePerLifetimeScope();
builder.RegisterType<LessonService>().As<ILessonService>().InstancePerLifetimeScope();
//register UIOMatic
builder.RegisterApiControllers(typeof(UIOMatic.Trees.UIOMaticTreeController).Assembly);
//register uContactor
builder.RegisterApiControllers(typeof(uContactorApiController).Assembly);
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
object reference not set to an instance of an object
Hi Tim
i'm sorry for late i post you this error before but i found the problem but i cannot solved
this code below is the reason when register dependencies
and this when i stop some code of register dependencies
it's work when i do this into register dependencies code
but code that i stopped make some problem to me so i ask you if you have any idea what can i do to solve this problem?
thanks Amr
Hi Amr,
I am having the same issue as you. Did you did an upgrade as well from V7.4.x to V7.5?
Cheers,
Laurens
Hi Laurens,
about the version i already run V7.5x
Seems it's working for me again.
I did a rebuild index & optimize index from the developer backend -> examine management.
Perhaps this could help you as well?
Hmm not sure, haven 't used it in combo Autofac, if you send project and db to tim at nibble dot be I can give a go at debugging...
And it also happens with other packages I see, https://our.umbraco.org/forum/developing-packages/80623-object-reference-not-set-to-an-instance-of-an-object
So not sure the error has to do with UI-O-Matic in that case
Have you followed docs for using IOC https://our.umbraco.org/documentation/reference/using-ioc ?
Ok seems this is due to autofac, you'll need to registed the UI-O-Matic tree controller, for details check the known issues doc, btw you'll need to do this for every third party tree
http://uiomatic.readthedocs.io/en/stable/13.KnowIssues/
HI Tim
Thank you i did this and it's work correctly
Awesome, thanks for confirming the fix!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.