-->

.Net 4.0 System.Web.Security.MembershipProvider am

2019-01-25 05:42发布

问题:

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.

回答1:

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.



回答2:

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