Hello,
I am using a custom Profile provider as follows:
public class Profile : ProfileBase {
[SettingsAllowAn onymous(false)]
public Bio Bio { get; set; }
[SettingsAllowAn onymous(true)]
public Visitor Visitor { get; set; }
public static Profile Get() {
return Create(Membersh ip.GetUser().Us erName) as Profile;
}
public static Profile Get(string username) {
return Create(username ) as Profile;
}
}
Visitor is a class has follows:
[Serializable()]
public class Visitor {
public CultureInfo Culture { get; set; }
}
On my web page I am overriding InitializeCultu re, by getting the value
of Visitor.Culture :
1 protected override void InitializeCultu re() {
2 base.Initialize Culture();
3 CultureInfo culture = Profile.Get().V isitor.Culture;
4 if (culture != null) {
5 Thread.CurrentT hread.CurrentCu lture = culture;
6 Thread.CurrentT hread.CurrentUI Culture = culture;
7 }
8 }
Because of code line 3 I always get an error on my profile provider:
1 public static Profile Get() {
2 return Create(Membersh ip.GetUser().Us erName) as Profile;
3 }
The error is on line 2 and says:
"Object reference not set to an instance of an object. Use the new
keyword to create an object instance."
What am I doing wrong?
Thanks,
Miguel
I am using a custom Profile provider as follows:
public class Profile : ProfileBase {
[SettingsAllowAn onymous(false)]
public Bio Bio { get; set; }
[SettingsAllowAn onymous(true)]
public Visitor Visitor { get; set; }
public static Profile Get() {
return Create(Membersh ip.GetUser().Us erName) as Profile;
}
public static Profile Get(string username) {
return Create(username ) as Profile;
}
}
Visitor is a class has follows:
[Serializable()]
public class Visitor {
public CultureInfo Culture { get; set; }
}
On my web page I am overriding InitializeCultu re, by getting the value
of Visitor.Culture :
1 protected override void InitializeCultu re() {
2 base.Initialize Culture();
3 CultureInfo culture = Profile.Get().V isitor.Culture;
4 if (culture != null) {
5 Thread.CurrentT hread.CurrentCu lture = culture;
6 Thread.CurrentT hread.CurrentUI Culture = culture;
7 }
8 }
Because of code line 3 I always get an error on my profile provider:
1 public static Profile Get() {
2 return Create(Membersh ip.GetUser().Us erName) as Profile;
3 }
The error is on line 2 and says:
"Object reference not set to an instance of an object. Use the new
keyword to create an object instance."
What am I doing wrong?
Thanks,
Miguel
Comment