Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8409005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:47:18+00:00 2026-06-09T23:47:18+00:00

I am getting this error now whenever I try to build. I just installed

  • 0

I am getting this error now whenever I try to build. I just installed Visual Studio 2012 and .Net 4.5, but this project is still on 2010.

Here is the line of code I am having issues with:

private static MethodInfo _encode;
public static string Encode(CookieProtection cookieProtection, byte[] buf, int count)
{
  return (string)_encode.Invoke(null, new object[] { cookieProtection, buf, count });
}

I receive an ArgumentException was unhandled by user code error saying, "Object of type 'System.Int32' cannot be converted to type 'System.Web.Security.Cryptography.Purpose'" Nothing has changed in my dev environment and my co-workers are not having the same problem, but they also do not have VS2012.

I found an article about Sitecore having this error, but this is the only place I have seen it pop up.

There they say, “This is because in .NET 4.5 there are some new namespaces in System.Web “

Their solution is to:

  • Uninstall VS11 if you have it installed
  • Uninstall .NET 4.5
  • Reinstall .NET 4

This seem like a ridiculous solution that 4.5 and 4 cant be on the same machine.

Does anyone know what may be causing this and any better solutions before I try to un-install and re-install a bunch of stuff?

A comment also says to try: </setting name="login.rememberlastloggedinusername" value="false" > but I don’t want to do that either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:47:20+00:00Added an answer on June 9, 2026 at 11:47 pm

    As @hvd alluded to, this code is using reflection to call internal methods which Microsoft changed in .NET 4.5.

    Fortunately .NET 4.0 introduced the System.Web.Security.MachineKey class with public Encode() and Decode() methods which accomplish basically the same thing as the internal methods in the CookieProtectionHelper. Note that cookies that were encrypted with CookieProtectionHelper.Encode() will not be able to be decrypted with MachineKey.Decode().

    Also note that in .NET 4.5, these methods are deprecated in favor of Protect() and Unprotect().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wrote a new web part and now I am getting this error
Getting this error when try to add an item to my repositories/context: Collection has
Okay, this is getting stupid, I have Microsoft Visual Studio 2008, was working fine,
I'm getting an BC30203: Identifier expected error in my ASP.NET MVC 4 project. I
I am getting this error now that I hit version number 1.256.0: Error 4
I am getting this error in my code now: Warning: mysql_num_rows(): supplied argument is
I have been getting this error for quite some time now and Google has
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Am getting this error message and matched my brackets and couldn't find anything wrong.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.