Installed/Updated date&time of a click once addin

Add-in Express™ Support Service
That's what is more important than anything else

Installed/Updated date&time of a click once addin
 
Subscribe
Ranjitha Nagendra




Posts: 23
Joined: 2021-01-11
Hi,

I have an Excel addin deployed through clickonce. How can I get the Installed/Updated date and time? I want to show this information on clicking my addin's ribbon button .

Thanks in advance,
Ranjitha
Posted 23 Nov, 2022 06:44:32 Top
Andrei Smolin


Add-in Express team


Posts: 18506
Joined: 2006-05-11
Hello Ranjitha,

Check section Customizing ClickOnce installations in the Add-in Express manual; see the PDF file in {Add-in Express installation folder}\Docs\.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Nov, 2022 08:46:41 Top
Ranjitha Nagendra




Posts: 23
Joined: 2021-01-11
Hi Andrei,

I am using ClickonceModule's OnclickOnceAction as you suggested. Here is my code :

private void ClickOnceModule1_OnClickOnceAction(object sender, ADXClickOnceAction action)
{
//registering
if (action.HasFlag(AddinExpress.MSO.ADXClickOnceAction.Register))
{
Properties.Settings.Default.InstallTime = DateTime.Now;
Properties.Settings.Default.Save();
}
}

I am storing the registering time in project settings to be able to show it to the user later on click of a ribbon button.(In the About window of my addin)

But for some reason, calling Properties.Settings.Default.Save(); in clickoncemodule is creating a separate user.config file which is different from application's user.config. So when Excel is started, application's user.config does not contain "InstallTime" property, so Last update date is showing DateTime.MinValue.

Am I doing it right? Please advise.

Thanks for your help
Ranjitha
Posted 07 Dec, 2022 09:37:40 Top
Andrei Smolin


Add-in Express team


Posts: 18506
Joined: 2006-05-11
Hello Ranjitha,

Make sure you use the same namespace in the same DLL when calling Properties.Settings.Default.Save(). If this is so, I suppose the issue belongs to your project only. If you can reproduce it on a new project, please send me the new project to the support email address; find it in {Add-in Express installation folder}\readme.txt; please make sure your email contains a link to this topic.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Dec, 2022 11:19:39 Top
Ranjitha Nagendra




Posts: 23
Joined: 2021-01-11
Hi Andrei,

I have sent you the project to the support email address. Looking forward to your reply.

Thanks in advance for the help.
Ranjitha
Posted 08 Dec, 2022 04:06:23 Top
Andrei Smolin


Add-in Express team


Posts: 18506
Joined: 2006-05-11
Hello Ranjitha,

Thank you. I've got the project and the code showed me what I missed.

I suppose the issue belongs to ClickOnce: the OnClickOnceAction event is executed in the ClickOnce sandbox and this is why saving the value causes creating another config file. Where's the new config file located?

I can't publish your project because of an exception that Add-in Express shows when I right-click the project and choose Publish. We look into this issue.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Dec, 2022 06:40:10 Top
Ranjitha Nagendra




Posts: 23
Joined: 2021-01-11
The one created by clickonce module is here : C:\Users\RanjithaNagendra\AppData\Local\Apps\2.0\Data\YZERLL3J.4A8\7DMEV0QD.X69\last..time_013ef56205cace98_0001.0000_0069383545d50dd1\Data\9.5.4661.0

The one created after running the application is here :
C:\Users\RanjithaNagendra\AppData\Local\Microsoft_Corporation\C__Users_RanjithaNagendra_Path_tkrehcb3zj0cqoyjgeeoo0qtmbgbwh0x\16.0.15726.20202
Posted 08 Dec, 2022 08:05:57 Top
Andrei Smolin


Add-in Express team


Posts: 18506
Joined: 2006-05-11
Thank you very much. I was right: the second one is stored in the ClickOnce cache. I've rebuilt your project and the exception gone. So I've published your add-in and researched this issue.

1. You can find the folder where your assembly is located:

string location = Assembly.GetExecutingAssembly().CodeBase;
string fullPath = new Uri(location).LocalPath; // path including the dll
string directoryPath = Path.GetDirectoryName(fullPath); // directory path


2.
In my case the assembly is located in {profile}\AppData\Local\Apps\2.0\XXXXXXXX.XXX\XXXXXXXX.XXX\Looooooong

While the user.config file is located in {profile}\AppData\Local\Apps\2.0\Data\XXXXXXXX.XXX\XXXXXXXX.XXX\Looooooong\Data\10.1.4703.0\

Where Looooooong is "last..time_013ef56205cace98_0002.0000_fb95140bd6e7e619" in my case.

10.1.4703.0 is the version of Add-in Express installed on my machine. In the Data path it is probably taken from the version of adxlauncher.exe.

3. I suggest that you use this information to find and read the user.config file created in the Data folder above.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Dec, 2022 09:41:15 Top
Ranjitha Nagendra




Posts: 23
Joined: 2021-01-11
Hi Andrei,

Can you please let me know If I am on the right path in achieving what I want:

Below is the code that will execute on click of a ribbon button:

private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed)
{
string location = Assembly.GetExecutingAssembly().CodeBase;
string fullPath = new Uri(location).LocalPath; // path including the dll
string directoryPath = Path.GetDirectoryName(fullPath);
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var dirName = new DirectoryInfo(directoryPath).Name;
Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyName[] assemblies = assembly.GetReferencedAssemblies();
string version = string.Empty;
foreach(AssemblyName an in assemblies)
{
if (an.Name.Contains("AddinExpress"))
version = an.Version.ToString();
}
var configpath = Path.Combine(appdata, @"Apps\2.0\Data\*", dirName, "Data", version, "user.config");

Configuration config = ConfigurationManager.OpenExeConfiguration(configpath);

MessageBox.Show( appdata + "\n\n" + dirName + "\n\n" + configpath);

}
Posted 12 Dec, 2022 04:03:11 Top
Andrei Smolin


Add-in Express team


Posts: 18506
Joined: 2006-05-11
Hello Ranjitha,

It looks like you are on the right path. There may be small details that require debugging but the general line seems to be okay.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Dec, 2022 04:55:55 Top