Doesn’t it seems very familiar and newbie error? Yes, It is. But I spent a lot of time to solve it, while I know what does this error means and how to solve it.
Working on VS2010 (.NET 4.0), I created the New Website project. I am using my custom membership provider in all my projects. When I compile the application, I receive error:
The type ‘System.Web.Security.MembershipProvider’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
So, Whats wrong!!. Yes I know, in .NET 4.0, Membership provider is moved from System.Web assembly to System.Web.ApplicationServices assembly. I checked the reference, it exists. Now, what to do? started pulling my hair. I googled, and every one is talking about to add the reference to the assembly. I’ve already added, now what should I do? Well, I removed the reference and re-added. but still same compilation error.
After spending lot of time, it just came in my mind to to run the website in debug mode to check, if the error is some other place. Well, page was displayed (It has form to create the user). I filled the form to create the user, clicked the button. I can’t believe, what happened? Oh! strange! Its working. No any run time error! User created successfully but still there is compile error on the same line. Oh God! what is this?? anyway, I left this error, because it is working.
I continued the development and created Data Components for Object data source. When I am going to configure Object data source, to use the data components, nothing is shown. I know the reason. This is because if there is compilation error and yes, obviously there is error (of membership provider). Now again problem. What to do now. I can not compile, because there is error in one of the page, while that page is working at same time without any error. pheeeeeeeewwwwwww. Time to pull hair again.
I read some posts on internet, which has not exact solution to my problem, but I got a clue and tried it and it worked for me. That is, I changed the Target framework from .NET 4.0 to 3.5 and compiled. Sure there will be some errors. Again I changed target framework from 3.5 to 4.0 and YES!!!!!!!!!!, it compiled successfully.
Isn’t this strange!
Leave a comment