This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Calling C# Dll CustomAction
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 12, 2008
02:58 AM
Calling C# Dll CustomAction
Hello,
I'm new to InstallShield, i'm wondering, how I could call my Installer-C#-DLL. I've previously used the VisualStudio Setup project to build my msi-file. I've used an Installer-DLL written in C# to do things during the installation, uninstall etc:
[FONT="Courier New"][SIZE="1"]using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
using System.Security.Cryptography.X509Certificates;
namespace CustomActions
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
setDeploymentUrlAndSign(Context.Parameters["CertFilePath"], Context.Parameters["CertPassword"],
Context.Parameters["NewDeploymentUrl"], Context.Parameters["deploymentManifestPath"]);
resignApplicationManifest(Context.Parameters["CertFilePath"], Context.Parameters["CertPassword"],
Context.Parameters["ApplicationManifestPath"], Context.Parameters["AppDir"]);
}
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
stateSaver.Add("CertFilePath", Context.Parameters["CertFilePath"].ToString());
stateSaver.Add("CertPassword", Context.Parameters["CertPassword"].ToString());
stateSaver.Add("NewDeploymentUrl", Context.Parameters["NewDeploymentUrl"].ToString());
stateSaver.Add("deploymentManifestPath", Context.Parameters["deploymentManifestPath"].ToString());
stateSaver.Add("ApplicationManifestPath", Context.Parameters["ApplicationManifestPath"].ToString());
stateSaver.Add("AppDir", Context.Parameters["AppDir"].ToString());
}
private void setDeploymentUrlAndSign(string certFilePath, string certPassword,
string newDeploymentUrl, string deploymentManifestPath)
{
string newDeploymentManifest = deploymentManifestPath + "_temp";
// Open the deployment file (.application)
DeployManifest deployManifest = ManifestReader.ReadManifest(deploymentManifestPath, false) as DeployManifest;
// Set the URL to the new url:
deployManifest.DeploymentUrl = newDeploymentUrl;
// Create a new manifest file (in a temp folder)
ManifestWriter.WriteManifest(deployManifest, newDeploymentManifest);
// Make sure the entered cert file exists
if (File.Exists(certFilePath))
{
// Construct cert object for cert
X509Certificate2 cert;
if (string.IsNullOrEmpty(certPassword))
{
cert = new X509Certificate2(certFilePath);
}
else
{
cert = new X509Certificate2(certFilePath, certPassword);
}
SecurityUtilities.SignFile(cert, null, newDeploymentManifest);
Console.WriteLine("Signed! new file: " + newDeploymentManifest);
}
}
private void resignApplicationManifest(string certFilePath, string certPassword,
string applicationManifestPath, string appDir)
{
string newApplicationManifest = applicationManifestPath + "_temp";
string[] appDirs = Directory.GetDirectories(appDir);
ApplicationManifest appManifest = ManifestReader.ReadManifest(applicationManifestPath, false) as ApplicationManifest;
appManifest.ResolveFiles(appDirs);
appManifest.UpdateFileInfo();
ManifestWriter.WriteManifest(appManifest, newApplicationManifest);
X509Certificate2 cert = new X509Certificate2(certFilePath, certPassword);
// Make sure the entered cert file exists
if (File.Exists(certFilePath))
{
// Construct cert object for cert
X509Certificate2 cert1;
if (string.IsNullOrEmpty(certPassword))
{
cert1 = new X509Certificate2(certFilePath);
}
else
{
cert1 = new X509Certificate2(certFilePath, certPassword);
}
SecurityUtilities.SignFile(cert1, null, newApplicationManifest);
Console.WriteLine("Signed! new file: " + newApplicationManifest);
}
}
}
}[/SIZE][/FONT]
Can I use this DLL in my Install-Shield project (*.ism File)? Or how can I use my C# Code in Install-Shield? How can I call an C# DLL or how should my DLL looks like for being called in Install-Shield and how can I call it?
Thanks for an answer:)
Kind regards,
Peter
I'm new to InstallShield, i'm wondering, how I could call my Installer-C#-DLL. I've previously used the VisualStudio Setup project to build my msi-file. I've used an Installer-DLL written in C# to do things during the installation, uninstall etc:
[FONT="Courier New"][SIZE="1"]using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
using System.Security.Cryptography.X509Certificates;
namespace CustomActions
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
setDeploymentUrlAndSign(Context.Parameters["CertFilePath"], Context.Parameters["CertPassword"],
Context.Parameters["NewDeploymentUrl"], Context.Parameters["deploymentManifestPath"]);
resignApplicationManifest(Context.Parameters["CertFilePath"], Context.Parameters["CertPassword"],
Context.Parameters["ApplicationManifestPath"], Context.Parameters["AppDir"]);
}
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
stateSaver.Add("CertFilePath", Context.Parameters["CertFilePath"].ToString());
stateSaver.Add("CertPassword", Context.Parameters["CertPassword"].ToString());
stateSaver.Add("NewDeploymentUrl", Context.Parameters["NewDeploymentUrl"].ToString());
stateSaver.Add("deploymentManifestPath", Context.Parameters["deploymentManifestPath"].ToString());
stateSaver.Add("ApplicationManifestPath", Context.Parameters["ApplicationManifestPath"].ToString());
stateSaver.Add("AppDir", Context.Parameters["AppDir"].ToString());
}
private void setDeploymentUrlAndSign(string certFilePath, string certPassword,
string newDeploymentUrl, string deploymentManifestPath)
{
string newDeploymentManifest = deploymentManifestPath + "_temp";
// Open the deployment file (.application)
DeployManifest deployManifest = ManifestReader.ReadManifest(deploymentManifestPath, false) as DeployManifest;
// Set the URL to the new url:
deployManifest.DeploymentUrl = newDeploymentUrl;
// Create a new manifest file (in a temp folder)
ManifestWriter.WriteManifest(deployManifest, newDeploymentManifest);
// Make sure the entered cert file exists
if (File.Exists(certFilePath))
{
// Construct cert object for cert
X509Certificate2 cert;
if (string.IsNullOrEmpty(certPassword))
{
cert = new X509Certificate2(certFilePath);
}
else
{
cert = new X509Certificate2(certFilePath, certPassword);
}
SecurityUtilities.SignFile(cert, null, newDeploymentManifest);
Console.WriteLine("Signed! new file: " + newDeploymentManifest);
}
}
private void resignApplicationManifest(string certFilePath, string certPassword,
string applicationManifestPath, string appDir)
{
string newApplicationManifest = applicationManifestPath + "_temp";
string[] appDirs = Directory.GetDirectories(appDir);
ApplicationManifest appManifest = ManifestReader.ReadManifest(applicationManifestPath, false) as ApplicationManifest;
appManifest.ResolveFiles(appDirs);
appManifest.UpdateFileInfo();
ManifestWriter.WriteManifest(appManifest, newApplicationManifest);
X509Certificate2 cert = new X509Certificate2(certFilePath, certPassword);
// Make sure the entered cert file exists
if (File.Exists(certFilePath))
{
// Construct cert object for cert
X509Certificate2 cert1;
if (string.IsNullOrEmpty(certPassword))
{
cert1 = new X509Certificate2(certFilePath);
}
else
{
cert1 = new X509Certificate2(certFilePath, certPassword);
}
SecurityUtilities.SignFile(cert1, null, newApplicationManifest);
Console.WriteLine("Signed! new file: " + newApplicationManifest);
}
}
}
}[/SIZE][/FONT]
Can I use this DLL in my Install-Shield project (*.ism File)? Or how can I use my C# Code in Install-Shield? How can I call an C# DLL or how should my DLL looks like for being called in Install-Shield and how can I call it?
Thanks for an answer:)
Kind regards,
Peter
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 12, 2008
05:49 AM
Create a component for the DLL, mark the dll as key file and then in the components properties set Installer class to Yes.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 12, 2008
08:23 AM
Thanks for the quick answer...hm could you explain that a bit more, how can I create a component for a dll and mark the dll? Also I can't find the properties, where I can set Installer Class to YES...
Kind regards,
Peter
Kind regards,
Peter
nikhilgupta wrote:
Create a component for the DLL, mark the dll as key file and then in the components properties set Installer class to Yes.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 17, 2008
02:04 AM
nikhilgupta wrote:
Create a component for the DLL, mark the dll as key file and then in the components properties set Installer class to Yes.
So finally i got it:
http://community.macrovision.com/showthread.php?t=168533&highlight=CoCreateObjectDotNet
kind regards,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 11, 2009
11:44 PM
I too trying to call C# custom action using installshield. We are using installshield 2009 Premier edition.
In my C# code, I am using the below function.
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
base.OnBeforeInstall(savedState);
--
}
public override void Install(System.Collections.IDictionary stateSaver)
{
}
Similarly calling commit, Uninstall,rollback Method.
I have a doubt, what to give in the Target field when we run the Custom action Wizard?
This custom action dll has other dependend dlls too. It seems http://community.macrovision.com/ link is no longer available.
Is there any other link which explains, how to call the C# custom action?
Really appreciate any help in this regard, if you have worked on similar requirement.
Regards
Devender
In my C# code, I am using the below function.
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
base.OnBeforeInstall(savedState);
--
}
public override void Install(System.Collections.IDictionary stateSaver)
{
}
Similarly calling commit, Uninstall,rollback Method.
I have a doubt, what to give in the Target field when we run the Custom action Wizard?
This custom action dll has other dependend dlls too. It seems http://community.macrovision.com/ link is no longer available.
Is there any other link which explains, how to call the C# custom action?
Really appreciate any help in this regard, if you have worked on similar requirement.
Regards
Devender
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 11, 2009
11:56 PM
I too was trying to call C# custom action using installshield. We are using installshield 2009 Premier edition.
In my C# code, I am using the below function.
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
base.OnBeforeInstall(savedState);
--
}
public override void Install(System.Collections.IDictionary stateSaver)
{
}
Similarly calling commit, Uninstall,rollback Method.
I have a doubt, what to give in the Target field when we run the Custom action Wizard?
This custom action dll has other dependend dlls too. It seems http://community.macrovision.com/ link
is no longer available.
Is there any other link which explains, how to call the C# custom action?
Really appreciate any help in this regard, if you have worked on similar requirement.
In my C# code, I am using the below function.
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
base.OnBeforeInstall(savedState);
--
}
public override void Install(System.Collections.IDictionary stateSaver)
{
}
Similarly calling commit, Uninstall,rollback Method.
I have a doubt, what to give in the Target field when we run the Custom action Wizard?
This custom action dll has other dependend dlls too. It seems http://community.macrovision.com/ link
is no longer available.
Is there any other link which explains, how to call the C# custom action?
Really appreciate any help in this regard, if you have worked on similar requirement.
