title: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)?
body: <p>I am trying to sort this annoying bug and I cant figure out the root cause of this exception. I went through the stack trace and still wasnt able to figure out the problem. I checked for he required dlls and everything looks fine to me. Any suggestions or advise is highly appreciated.</p>
  
  <p>Stack Trace:-</p>
  
  <pre><code>[FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
     System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
     System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
     System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark) +40
     System.Type.GetType(String typeName) +30
     System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow) +108
     System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +88
     System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func`3 handleFailedLookup) +77
     System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key) +81
     System.Data.Entity.Infrastructure.DependencyResolution.&lt;&gt;c__DisplayClass1.&lt;GetService&gt;b__0(Tuple`2 k) +26
     System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +62
     System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key) +140
     System.Data.Entity.Infrastructure.DependencyResolution.&lt;&gt;c__DisplayClass3.&lt;GetService&gt;b__0(IDbDependencyResolver r) +19
     System.Linq.WhereSelectArrayIterator`2.MoveNext() +58
  </code></pre>
  
  <p>C# code -</p>
  
  <pre><code> public async Task&lt;ActionResult&gt; Register(RegisterViewModel model)
      {
          if (ModelState.IsValid)
          {
              var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
              var result = await UserManager.CreateAsync(user, model.Password);
  
              if (result.Succeeded)
              {
                  await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
  
                  // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                  // Send an email with this link
                  // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                  // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                  // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking &lt;a href=\"" + callbackUrl + "\"&gt;here&lt;/a&gt;");
  
                  return RedirectToAction("Index", "Home");
              }
              AddErrors(result);
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>The exception is thrown at this specific line of code -</p>
  
  <pre><code> public ApplicationUserManager UserManager
          {
              get
              {
                  return _userManager ?? HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
              }
              private set
              {
                  _userManager = value;
              }
          }
  </code></pre>
  
  <p>//The following method returns null and throws exception at  <code>return _userManager ?? HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();</code></p>