Skip to content

Unhandled Exception after Unity update #5

@balagun

Description

@balagun

Description

I worked with last Unity full package version 5.8.13 with no any problems for a long time. But after updating to version 5.10. I get the <Unhandled Exception:
CommonServiceLocator.ActivationException: Activation error occurred while trying to get instance of type MyService, key "">.
As it was prescribed due starting with version 5.9.0 all Unity packages are available as individual NuGet packages, after updating I also installed the Unity.ServiceLocation package.
So, the code is compiling without any errors but now I get this exception after application runned.

To Reproduce

using CommonServiceLocator;
using Unity;
using Unity.Lifetime;
using Unity.ServiceLocation;
...
var container = new UnityContainer();
container.RegisterType<MyService>(new ContainerControlledLifetimeManager());
...
var locator = new UnityServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => locator);
...
var _myService= ServiceLocator.Current.GetInstance<MyService>(); // An exception occurs here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions