Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolateyGH-584) Load licensed version
Browse files Browse the repository at this point in the history
If the license is found to be a licensed version, attempt to load the
assembly and register the components provided by the licensed version.
Provide helpful error messages when loading the assembly fails for some
reason.
ferventcoder committed Jan 27, 2016

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 23049ec commit 15d92fd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
@@ -28,10 +28,10 @@ namespace chocolatey.console
using infrastructure.configuration;
using infrastructure.extractors;
using infrastructure.filesystem;
using infrastructure.information;
using infrastructure.licensing;
using infrastructure.logging;
using infrastructure.registration;
using infrastructure.services;
using resources;
using Console = System.Console;
using Environment = System.Environment;
@@ -53,6 +53,29 @@ private static void Main(string[] args)
Bootstrap.startup();

var license = LicenseValidation.validate();
if (license.is_licensed_version())
{
try
{
var licensedAssembly = Assembly.LoadFile(ApplicationParameters.LicensedAssemblyLocation);
license.AssemblyLoaded = true;
license.Version = VersionInformation.get_current_informational_version(licensedAssembly);
Type licensedComponent = licensedAssembly.GetType(ApplicationParameters.LicensedComponentRegistry, throwOnError: true, ignoreCase: true);
SimpleInjectorContainer.add_component_registry_class(licensedComponent);
}
catch (Exception ex)
{
"chocolatey".Log().Error(
@"Error when attempting to load chocolatey licensed assembly. Ensure
that chocolatey.licensed.dll exists at
'{0}'.
The error message itself may be helpful as well:{1} {2}".format_with(
ApplicationParameters.LicensedAssemblyLocation,
Environment.NewLine,
ex.Message
));
}
}
var container = SimpleInjectorContainer.Container;

var config = container.GetInstance<ChocolateyConfiguration>();

0 comments on commit 15d92fd

Please sign in to comment.