views:

179

answers:

1

I have an automation addin for excel developed using C#. How do I package and distribute it ? Also when the addin is installed for the first time, I want a username and password check to pop for the first time.

How can I go about doing this ?

thanks

A: 

Visual Studio creates a setup project for each Add-in project. You could start by using that. It produces an MSI file that you can distribute.

About the second part - if you stay with Studio-generated setup you probably cannot add custom dialogs to installation. You'll need some tool that builds the installations.

How about asking for username and password on the first use? This way the installation remains simple. In my experience every question during installation increases the risk that the user says "WTF, why do I have to answer these stupid questions. Cancel".

To ask for username and password on the first use only you have to save them somewhere after asking, so that next time you know them. Approved Microsoft way is saving them in Settings. By default Studio creates Settings file in your peoject just for that. Just add two variables to that file with empty default values. Mark them as User variables (not the Application variables).

From your add-in, access them as Properties.Setings.VariableName.

When your add-in starts, check if you have the username and password in settings. If they are empty, ask and save.

if (string.IsNullOrEmpty(Properties.Settings.Default.UserName))
{
   string name;
   string password;
   //ask for name and password, replace with your code
   AskForUserandPassword(out name, out password);
   Properties.Settings.Default.UserName=name;
   Properties.Settings.Default.Password=password;
   Properties.Settings.Default.Save()
}

Physically, this is saved somewhere deep in user directory in an XML file.

yu_sha
Thanks. Username password is on the first use only. How can that be achieved?
Sandy
See updated answer
yu_sha
Hi,Mine is a C# class library project for the automation addin and there is no default msi file created by VS that I can distribute.I am creating a set-up file for the automation addin. When I run the set up , I want the addin to appear in the Excel automation addin list( Tools-->Addins-->Automation addin in Excel) so that I can directly include it in my Excel application. How do I go about it ? I created a setup project following the link here http://www.dreamincode.net/forums/showtopic58021.htm and the addin does not appear in the automations addin list. Am I missing something here ?
Sandy
You are probably missing security. At least on Vista, add-ins need FullTrust to run. You need to add a custom action to achieve this. Official microsoft way is described here. Pretty complicated. http://msdn.microsoft.com/en-us/library/bb332051.aspx. You don't necessarily have to modify the bootstrapper the way they suggest, but definitely have a look at the way they set security.
yu_sha
My security levels are set to Full Trust only. I still do not see my addin in the list of automation addins. !
Sandy
My sympathies, I am struggling with the same problem. It really could be anything, perhaps a missing DLL.Here's another link: http://blogs.msdn.com/vsod/archive/2008/04/22/Troubleshooting-com-add-in-load-failures.aspx
yu_sha