I’m writing a console application, that uses SharePoint object model to manipulate data inside of SharePoint.
There are two variables:
SPWeb spWeb
string formsUser //username
and I’m trying to resolve user
SPUser userF = spWeb.EnsureUser(formsUser);
This line keeps throwing exception:
Could not load file or assembly “System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” or one of its dependencies. The system cannot find the specified file.
My project’s Target framework is .Net Framework 3.5. I have reference to System.Web.Extensions.dll, version 3.5.0.0..
What I cannot understand:
- Why is my application expecting this assembly in version
4.0.0.0and not in3.5.0.0? - Why this line would be throwing exception regarding
System.Web.Extensions, if everything in this line is aboutMicrosoft.SharePointassembly
Update:
in above example I’m using forms based user, so the string is something like: i:0#.f|someprovider|john.doe. If I use Windows based user instead, so i:0#.w|domain\john.doe, this exception is not thrown.
Is there any chance, that SPUser is secretly trying to use System.Web.Extensions, and fails?
I found solution:
The
app.configfile in my application containssystem.web/membershipandroleManagersections. And there was reference to theSystem.Web.Extensions, Version=4.0.0.0