Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net 4.0 System.Web.Security.MembershipProvider ambiguous reference?

I have recently upgraded my BlogEngine.Net installation to 1.6 and .Net 4.0, however, I did not build BlogEngine.Core when I performed the upgrade. However, when I try to build the BlogEngine.Core project now, the compile fails because it cannot load the symbols for (System.Web.Security.)MembershipProvider. I believe this to be a .Net/C#/user problem rather than a BlogEngine issue.

The project has a reference to the library System.Web, and the class file (which inherits from MembershipProvider) includes a Using for System.Web.Security. With ReSharper enabled, IntelliSense indicates confusion as to which membership provider to use giving a choice of two libraries of the same name (System.Web.Security).

What could have caused this ambiguous reference? How can I determine which two libraries are being referenced? Nothing obvious indicates a duplicate reference. Then again, the obvious is really obvious once you see it.

like image 458
wilk Avatar asked Sep 14 '10 20:09

wilk


2 Answers

Problem solved. System.Web.Security namespace is a member of System.Web, however, it is also a member of System.Web.ApplicationServices. The project had a reference to System.Web, and a using statement referenced System.Web.Security, so IntelliSense did not throw a flag when specifying the class. However, the project was missing a reference to to System.Web.ApplicationServices. The project had a reference to the class, but it could not load the class because the containing assembly (...ApplicationServices) was missing.

like image 185
wilk Avatar answered Sep 25 '22 04:09

wilk


I just dealt with this same issue when creating a custom membership provider for my web application. You need to remove the reference to System.Web and add the following references. - System.Web.ApplicationServices - System.Configuration

like image 31
idflyfish Avatar answered Sep 21 '22 04:09

idflyfish