profile.PhotoUrl 'profile.PhotoUrl' threw an exception of type 'System.NullReferenceException'

Oct 15, 2015 at 3:15 AM
When using the mysql data provider I get the following error:
profile.PhotoUrl 'profile.PhotoUrl' threw an exception of type 'System.NullReferenceException'

Error is foundin sidebar.cshtml at this location:
@using BlogEngine.Core
@using BlogEngine.Core.Data.Services
@{
    var name = Security.CurrentUser.Identity.Name;
    var email = Membership.Provider.GetUser(name, true).Email;
    var profile = AuthorProfile.GetProfile(name);

    var src = profile.PhotoUrl;
    if (string.IsNullOrEmpty(src))
    {
        src = Avatar.GetSrc(email);
    }
}
Oct 15, 2015 at 9:50 AM
Looks like a missing null check on the profile object.
@using BlogEngine.Core
@using BlogEngine.Core.Data.Services
@{
    var name = Security.CurrentUser.Identity.Name;
    var email = Membership.Provider.GetUser(name, true).Email;
    var profile = AuthorProfile.GetProfile(name);

    var src = string.Empty;
    if (profile != null)
    {
        src = profile.PhotoUrl;
    }
    if (string.IsNullOrEmpty(src))
    {
        src = Avatar.GetSrc(email);
    }
}
Oct 15, 2015 at 12:51 PM
I'll try that then rebuild the solution. If it fixes it I'll submit it to the github repo. I also made changes to the web.config for the mysql data provider as there was error in the assemblies.
Oct 16, 2015 at 1:36 PM
Edited Oct 16, 2015 at 1:38 PM
Getting the following:
An exception of type 'System.NullReferenceException' occurred in App_Web_dd4s1i0v.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.

Looks like the issue is here:
<div class="user-nav">
    <img src="@src" />
    <div class="user-nav-info">
        <div class="user-nav-name"><a href="~/admin/#/security/profile">@profile.DisplayName</a></div>
        <ul class="user-nav-options">
            <li><a href="~/" target="_blank"><i class="fa fa-globe"></i> View Blog</a></li>
            <li><a href="~/Account/login.aspx?logoff"><i class="fa fa-sign-out"></i> Sign Out</a></li>
        </ul>
    </div>
</div>
The stop is here
file">@profile.DisplayName
Oct 16, 2015 at 6:59 PM
Looks like a missing null check again.
Simple enough oversight if that is the case, and if so, might be worth checking where else profile is used.

I have a local copy of BE 3.1.1.3 but can't seem to find this code, so unable to test, but something along the lines of the following might be worth a try.
//From
<div class="user-nav-name"><a href="~/admin/#/security/profile">@profile.DisplayName</a>
//To
<div class="user-nav-name"><a href="~/admin/#/security/profile">@(profile != null ? profile.DisplayName : Security.CurrentUser.Identity.Name)</a>
Oct 19, 2015 at 3:29 PM
Try editing the web.config to use a mysql database. That's where the error is. It build correctly then comes up. It's when you log in and go to "dashboard".