4

We've recently upgraded our solution to .NET 4.5.

I've come to understand that System.Web.Security.MembershipUser has been moved to System.Web.ApplicationServices.dll.

I've added a reference to our website in the web.config file:

<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

I've used the proper "using" statement in the c# page in question:

using System.Web.ApplicationServices;

And still, the following code throws an error on MembershipUser:

MembershipUser u = Membership.GetUser(User.Identity.Name);

I'm entirely unsure of what to do at this point. I've been researching this all day and have applied a few changes (namely the web.config change) and yet this c# page will still not recognize the changes and the error remains.

What's odd is that the site will build and be usable even with this existing error, with the exception of the "Change Password" functionality this code was intended to address.

Can anybody possibly point me as to where I might be missing references or assemblies?

RockiesMagicNumber
  • 462
  • 2
  • 10
  • 20
  • 1
    Did you add the reference to the project references? – bowlturner Aug 06 '14 at 19:42
  • You also might wanna add, (in the web coffin part) an assembly biding with binds all the versions lower then 4.0 to the 4.0 file so you're sure your using the newest dll http://msdn.microsoft.com/en-us/library/twy1dw1e(v=vs.110).aspx – Edo Post Aug 06 '14 at 19:44
  • @bowlturner yeah, I went through the "Add Reference" dialogue on the website portion of the solution and it added the line to the web config. – RockiesMagicNumber Aug 06 '14 at 19:47
  • @EdoPost we have this: ` ` – RockiesMagicNumber Aug 06 '14 at 19:47
  • 1
    @RockiesMagicNumber try adding the following assembly binding to: This makes sure there is no reference to the an older system.web.applicationServices.dll if your class is moved in the new version and it tries to get it out of an old one it can not find it – Edo Post Aug 06 '14 at 19:53
  • Hm. Well, regrettably enough, adding that line to the web.config and building the site didn't help, MembershipUser still throws an error. – RockiesMagicNumber Aug 06 '14 at 20:10

2 Answers2

2

OK, so I think I got this. Part of the problem was in our Web.config as it would seem.

I changed the CompilerVersions for c# and vb to 4.0:

<system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="OptionInfer" value="true"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>

Additionally, our compilation target framework was not specifying 4.0.

<compilation debug="true" batch="false" batchTimeout="7200" targetFramework="4.0">

Upon building the site now, MembershipUser now shows up as I'd expect it to. Huzzah.

This upgrade to 4.5 from 2.0 has not been going well.

RockiesMagicNumber
  • 462
  • 2
  • 10
  • 20
  • 1
    I think this issue is related: http://stackoverflow.com/questions/3314469/how-do-i-fix-the-compilerversion-iis-error – Sergey Mar 19 '15 at 01:14
0

For .NET Framework 4.0 or above add reference of System.Web.ApplicationServices.dll

Syed Nasir Abbas
  • 1,722
  • 17
  • 11