Search code examples
c#.netreferencenugetsquirrel.windows

public class inaccessible due to protection level


I'm using Squirrel.Windows as an update framework for my application and I upgraded from 1.4.4 to the latest version 1.5.2 and after upgrading via NuGet the UpdateManager class became inaccessible due to it's protection level.

I created a sample project and imported the Squirrel.Windows nuget package via NuGet and I was able to instantiate an instance of the UpdateManager class without issue. I tried cleaning out all the NuGet packages related to the Squirrel.Windows project and cleaned up any information remaining in the csproj that was related to it, after importing the package again I was still unable to access the class.

namespace Our.Core 
{
    public class Launcher
    {        
        public static void Main(string[] args)
        {
            new Launcher(args);
        }

        public async Task<bool> TryUpdate(string[] args)
        {
            try
            {
                using (var mgr = new UpdateManager(UpdatePath, null, null, null))
                {
                    Log.Information("Checking for updates");
                    var updateInfo = await mgr.CheckForUpdate();
                    if (updateInfo.ReleasesToApply.Any())
                    {
                        Log.Information("Downloading updates");
                        await mgr.DownloadReleases(updateInfo.ReleasesToApply);
                        Log.Information("Applying updates");
                        await mgr.ApplyReleases(updateInfo);

                        return true;
                    }
                    Log.Information("No updates found.");

                    return false;
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Error while updating");
                return false;
            }
        }
    }
}

Solution

  • The problem turned out to be that after upgrading the library, the reference in the project had its Specific Version property toggled to false. This caused Visual Studio to be unable to correctly reference the correct version of the library.

    Moral of the story, make sure to check your version and that your specific version check is true if you need to use a specific version!