public BaseActivationFactory(string typeNamespace, string typeFullName)
        {
            var runtimeClassId = TypeExtensions.RemoveNamespacePrefix(typeFullName);

            // Prefer the RoGetActivationFactory HRESULT failure over the LoadLibrary/etc. failure
            int hr;

            (_IActivationFactory, hr) = WinrtModule.GetActivationFactory(runtimeClassId);
            if (_IActivationFactory != null)
            {
                return;
            }

            var moduleName = typeNamespace;

            while (true)
            {
                try
                {
                    (_IActivationFactory, _) = DllModule.Load(moduleName + ".dll").GetActivationFactory(runtimeClassId);
                    if (_IActivationFactory != null)
                    {
                        return;
                    }
                }
                catch (Exception) { }

                var lastSegment = moduleName.LastIndexOf(".");
                if (lastSegment <= 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
                moduleName = moduleName.Remove(lastSegment);
            }
        }
 public static DllModule Load(string fileName)
 {
     lock (_cache)
     {
         DllModule module;
         if (!_cache.TryGetValue(fileName, out module))
         {
             module           = new DllModule(fileName);
             _cache[fileName] = module;
         }
         return(module);
     }
 }