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

与世无争的帅哥 提交于 2019-11-27 23:24:30

问题


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



来源:https://stackoverflow.com/questions/3712467/net-4-0-system-web-security-membershipprovider-ambiguous-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!