I'm trying create a NuPackage

Vote:
 

Hello guys,

I create my NuGet Package to install my add on. After install I restart the iss and I get this message:

Cannot create an abstract class.

I don't know why I can't write in a log as well.

Some one can help me?

namespace Project.Manager
{
[ModuleDependency(typeof(EPiServer.Packaging.PackagingInitialization))]
public abstract class PackageInitializer : IPackageNotification
//: IInitializableModule
{
static ILog log = log4net.LogManager.GetLogger(typeof(PackageInitializer));

public PackageInitializer()
{

}

public void AfterInstall()
{
log.Error("Begin");

WriteConnectionString();

CopyFiles();

//Execut SQL creation.
log.Error("Done");
}

 

public void AfterUpdate()

{
log.Error("AfterUpdate");
//System.IO.Directory.CreateDirectory("AfterUpdate");
//throw new NotImplementedException();
}

public void BeforeUninstall()
{
//System.IO.Directory.CreateDirectory("BeforeUninstall");
//throw new NotImplementedException();
}
}
}

 

 

#77466
Nov 20, 2013 7:09
Vote:
 

The problem is that the system cannot instantiate your initializable module because it is abstract.

You can find more information about initializable module or add-on initializer in Add-ons developer guide.

Also see example implementations in Sample add-on source code.

Consider implementing usual non-abstract public initializable module, if you need only initialization logic that should run when site starts. Something like the following:

    [InitializableModule]
    public class MyInitializableModule : IInitializableModule
    {
        /// <summary>
        /// Executes on initialization.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Initialize(InitializationEngine context)
        {
        }

        /// <summary>
        /// Executes on uninitialization.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Uninitialize(InitializationEngine context)
        {
        }

        /// <summary>
        /// executes on preload
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        public void Preload(string[] parameters)
        {
        }
    }

    

Consider inheriting your initializer from EPiServer.Packaging.PackageInitializer class if you need to run some code after add-on is installed, updated or before add-on is removed. Implement corresponding methods of base class. Note that package/add-on initializer is also initializable module, don't forget to call base implementation when overriding Initialize, Uninitialize and Preload methods.

    [ModuleDependency(typeof(Packaging.PackagingInitialization))]
    [ModuleDependency(typeof(Web.InitializationModule))]
    public class MyAddonInitializer : Packaging.PackageInitializer
    {
        /// <summary>
        /// Executes after add-on is installed.
        /// </summary>
        public override void AfterInstall()
        {
        }

        /// <summary>
        /// Executes after add-on is updated.
        /// </summary>
        public override void AfterUpdate()
        {
        }

        /// <summary>
        /// Executes before add-on is uninstalled.
        /// </summary>
        public override void BeforeUninstall()
        {
        }

        /// <summary>
        /// Initializes the module.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Initialize(InitializationEngine context)
        {
base.Initialize(context); // and then do something specific for this add-on initializer... } }

    

#77486
Edited, Nov 20, 2013 9:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.