Upgrade to Unity container throwing "COMException: Retrieving the COM class factory"

44 Views Asked by At

I have recently upgraded my project Unity Container to 5.11.10 version and below is the code

using CommonServiceLocator;
using Unity;
using Unity.Injection;
using Unity.Lifetime;
using Unity.ServiceLocation;

var container = new UnityContainer();
var locator = new UnityServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => locator);
container.RegisterType(typeof(myclass));
var instance = ServiceLocator.Current.GetInstance(myclass);

The code is throwing below error while referring myclass (var instance... is in another project though) , all the projects targets are set to x86

CommonServiceLocator.ActivationException: 'Activation error occurred while trying to get instance of type myclass, key ""'
COMException: Retrieving the COM class factory for component with CLSID {01DFEFEE-D2DA-4F55-AA57-746A3DFB3151} 
failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
0

There are 0 best solutions below