开发者

Packaging an excel addin

开发者 https://www.devze.com 2022-12-15 21:11 出处:网络
I have an automation addin for excel developed using C#. How do I package and distribute it ? A开发者_如何转开发lso when the addin is installed for the first time, I want a username and password check

I have an automation addin for excel developed using C#. How do I package and distribute it ? A开发者_如何转开发lso 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消