Hi I am basically trying to create my own Facebook Login (and create a local account). I have everything working except this one bit: After creating the account I am trying to setup a basic profile and tie it back to the account. I am able to create the account but when I try to cast the providerkey to a Guid, it comes back null. If I try to not cast it I get the error “cannot implicitly convert object to Guid” The providerkeyvalue itself is not null and is in a format like this {7092216C-943F-4D30-9432-6CD10CF3447E}
// Attempt to register the user
MembershipCreateStatus createStatus;
Membership.CreateUser(fbprofile.first_name + fbprofile.id, GenerateRandomPassword(8), fbprofile.email, null, null, true, null, out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
MembershipUser user = Membership.GetUser(fbprofile.first_name + fbprofile.id); //Gotta get the GUID and tie it to the profile
profile.UserID = (Guid)user.ProviderUserKey;
}else{
}
EDIT: If it makes a difference, the ProviderUserKey is set to just object in the membership class.
Based on your comments, your problem is that you are not creating an instance of the Profile class. You cannot assign values to null objects without first creating an instance of that object.
“Object Reference not set to instance of object” means that you are trying to dereference a null object, that is you are trying to access a member or property of an object that is null.
On that line of code, there are only two things that will cause that error. Either profile is null or user is null, if either of them are null, you will get this error. That is the only thing it could possibly be.