Click here to Skip to main content
15,885,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In visual studiuo 2010 after creation of installer for project.

Right click (on created) installer-->view-->custom actions-->In that Install folder when i added the Update manifest-->right click on update manifest go to properties in the custom action data field added path for project.

path which i added is
/targetDir="[TARGETDIR]/" /documentName="Lokkonfiguration.xlsx" /assemblyName="Lokkonfiguration.dll"

Next, when am trying to Install an error occurs which is , Error 1001 could not create a persistence object for the specified file.

in update manifest installer.cs code contains
C#
namespace UpdateManifest
{
    [RunInstaller(true)]
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
    public partial class Installer1 : Installer
    {
        public Installer1()
        {
            InitializeComponent();
        }

        // Override Install to update the customization location
        // in the application manifest.
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            // Call the base implementation.
            
            base.Install(stateSaver);
            UpdateApplicationManifest();
        }

        private void UpdateApplicationManifest()
        {
            // Define the parameters passed to the task.
            string targetDir = this.Context.Parameters["targetDir"];
            string documentName = this.Context.Parameters["documentName"];
            string assemblyName = this.Context.Parameters["assemblyName"];

            if (String.IsNullOrEmpty(targetDir))
                throw new InstallException("Cannot update the application manifest. The specified target directory name is not valid.");
            if (String.IsNullOrEmpty(documentName))
                throw new InstallException("Cannot update the application manifest. The specified document name is not valid.");
            if (String.IsNullOrEmpty(assemblyName))
                throw new InstallException("Cannot update the application manifest. The specified assembly name is not valid.");

            // Get the application manifest from the document.
            string documentPath = Path.Combine(targetDir, documentName);
            ServerDocument serverDocument = new ServerDocument(documentPath, FileAccess.ReadWrite);
            try
            {
                AppManifest appManifest = serverDocument.AppManifest;
                //bool allUsers = String.Equals(documentPath, "1");
                string assemblyPath = Path.Combine(targetDir, assemblyName);
               appManifest.Dependency.AssemblyPath = assemblyPath;
               serverDocument.Save();
            }
            finally
            {
                if (serverDocument != null)
                {
                    serverDocument.Close();
                }
            }
        }
    }
}
Posted
Updated 28-Nov-14 2:01am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900