Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > How do I do a Shared Service installation with MSI
 

How do I do a Shared Service installation with MSI

I have a couple of application that use the same service. I'm having problems getting the service to uninstall when the the last of the applications is uninstalled. All is done with Visual Studio 9, The service is managed via a service control table in the msi. (I'm open to a merge module too, even though I have been down that path already).

The scenarios:
1)
Install App1 -> the service is installed
Uninstall App1 -> the service is removed

2)
Install App1 -> the service is installed
Install App2 -> the service is updated if a app2 uses a newer version
Uninstall App2 -> the service is not changed
Uninstall App1 -> the service is removed

Using the shared legacy flag doesn't seem to work correctly (it never uninstalls the service)
To further complicate the situation I need to install the interface dll to the GAC and it doesn't seem as though it will do that untill the service is started so the dll needs to be copied with the exe and then put in the GAC (GAC needs to be managed like the service in the above scenarios) and I have an XML file used to determine the ports where the service and its spawned processes will communicate so those can't be removed willy-nilly either. I'm having a real hard time finding the right combinations to make this all work... any help would be greatly appreciated.

beejerdude  Thursday, August 13, 2009 8:24 PM
Hello,

ProductVersion is a Property within support by Windows Installer. To pass this value to Custom action, we can set the CustomActionData Property in the Property Window of the custom action, for example, /Version="[ProductVersion]". And then, in the installer class, we can get the version using the following code.

protected override void OnBeforeInstall(IDictionary savedState)
{
string version = this.Context.Parameters["Version"].ToString();
System.Windows.Forms.MessageBox.Show(version);
base.OnBeforeInstall(savedState);
}

More information
http://msdn.microsoft.com/en-us/library/aa370859%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/2w2fhwzz.aspx
http://msdn.microsoft.com/en-us/library/9cdb5eda.aspx

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer bybeejerdude Monday, August 24, 2009 9:58 PM
  •  
Rong-Chun Zhang  Monday, August 24, 2009 1:06 PM
Hello,

Thanks for your posting on MSDN forum.

First, let me confirm my understanding with you, you want to install the shared service application between your applications, that mean if uninstalling either of the application(app1 or app2), the service application is not uninstalled, however, if uninstalling both the application(app1 and app2), the service application is uninstalled too. Please correct me if there is any misunderstanding.

To installed a shared component, I suggest you use the Merge Module. Merge modules are used to deliver shared code, files, resources, registry entries, and setup logic to applications as a single compound file. It use a "count" internally to control the shared the component, that is when the count becomes 0, the shared component gets uninstalled. For example, if we install app1 and app2, the merge module count is 2, if we uninstall either of them(app1 or app2), the count becomes 1, if we uninstall both of them(app1 and app2), the count becomes 0 and the shared component gets uninstalled.

If you have any additional question, feel free to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Friday, August 14, 2009 8:38 AM
It sounds like you do understand part of the problem. As far as the counting goes... App1 and App2 can/may be installed at any time, so I would have to find a way to persist the reference count. In truth I got it to work via a service table entry, but now I have other issues. I'm going to attempt to handle installing, uninstalling, and upgrading via a custom action. Since I have keys in the registry telling me which versions of my products are installed I can get most of what I need to make decisions. THe problem I am grappling with now is getting the 'ProductVersion' property in the CustomAction to make decisions.
beejerdude  Friday, August 21, 2009 3:41 PM
Hello,

ProductVersion is a Property within support by Windows Installer. To pass this value to Custom action, we can set the CustomActionData Property in the Property Window of the custom action, for example, /Version="[ProductVersion]". And then, in the installer class, we can get the version using the following code.

protected override void OnBeforeInstall(IDictionary savedState)
{
string version = this.Context.Parameters["Version"].ToString();
System.Windows.Forms.MessageBox.Show(version);
base.OnBeforeInstall(savedState);
}

More information
http://msdn.microsoft.com/en-us/library/aa370859%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/2w2fhwzz.aspx
http://msdn.microsoft.com/en-us/library/9cdb5eda.aspx

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer bybeejerdude Monday, August 24, 2009 9:58 PM
  •  
Rong-Chun Zhang  Monday, August 24, 2009 1:06 PM

You can use google to search for other answers

Custom Search

More Threads

• Patching dll files with ClickOnce
• Clickonce run SQL Scripts
• Setup Problem
• Problem with Shortcuts
• How to create Setup app which also allow install database ?
• Reference Files
• ClickOnce activation through SSL device.
• Deployment and patching solutions
• Publish with .dll files
• Click Once Concerns With Full Blown Application