How to locate the folder where the COM Add-In DLL is installed

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

How to locate the folder where the COM Add-In DLL is installed
 
Choon Teck Lee




Posts: 5
Joined: 2007-01-24
Hi,

How to locate the folder where the COM Add-In DLL is installed in end user machine ? Someone recommended using the following code in previous post :

string directory = Assembly.GetExecutingAssembly().Location;

However, the "directory" value given was not the folder where the COM Add-In is installed. The "directory" value given is "C:\Documents and Settings\user\Local Settings\Application Data\assembly\dl3\OYVV2CWT.5BT\8W2OREMR.DJR\02d7b451\aa728e8d_873fc701\Toolbar.DLL" which is NOT the installation folder.

Thank you.
Posted 24 Jan, 2007 02:47:20 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Choon.

You can use the 'this.GetType().Assembly.Location' code in the AddinModule class to obtain the add-in directory.


P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 24 Jan, 2007 08:43:53 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Choon, we can't answer your emails. Please use the correct email address.
Posted 24 Jan, 2007 10:23:36 Top
Choon Teck Lee




Posts: 5
Joined: 2007-01-24
Hi,

I didnt manage to get the directory where the Add-In is installed by using 'this.GetType().Assembly.Location'. Instead of getting the installation directory of the Add-In, i get the following path "C:\Documents and Settings\user\Local Settings\Application Data\assembly\dl3\OYVV2CWT.5BT\8W2OREMR.DJR\02d7b451\aa728e8d_873fc701\Toolbar.DLL". It seems like there is another copy of the Add-In DLL in that path.

So, how can i get the directory where the Add-In is installed ? Thank you.
Posted 24 Jan, 2007 20:58:50 Top
Jason Crabtree




Posts: 19
Joined: 2007-01-23
I am also struggling a bit with this, as I get similar results with the Location property. I found that I can use GetType().Assembly.CodeBase to get the install directory, but it's in URL form. Is there a way to convert from a URL to a normal Path?

Thanks
Posted 24 Jan, 2007 23:56:17 Top
Martin Mizzell


Guest


Hi,

It is late and im a little groggy but i think this may work:


string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
FileInfo fileinFo = new FileInfo(codeBase.Replace("file:///", String.Empty);
return fileinFo.Directory.FullName;


Martin
Posted 25 Jan, 2007 01:05:25 Top
Jason Crabtree




Posts: 19
Joined: 2007-01-23
Thanks for the reply Martin. The code below also seemed to work for me. It's C++ format though, and it's too late and I'm too tired to change the "->" to ".". I convert the "message" string to a URI, and then use the LocalPath property to return the URI back as a string in the normal path format. Worked for me anyways :).

message = this->GetType()->Assembly->CodeBase;
Uri *test = new Uri(message);
message = test->LocalPath;
Posted 25 Jan, 2007 01:50:02 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Choon.

Do you use the ADX loader? If so, please check the 'shadowCopyEnabled' attribute in the adxloader.dll.manifest file. If it is 'true', the Location property will return the cached location. That is why you can't use it.
Posted 25 Jan, 2007 07:20:18 Top
Jason Crabtree




Posts: 19
Joined: 2007-01-23
Hi Sergey,

I use the ADX loader, and I'm having the same problem as Choon. When I open my manifest file though, there is only one thing defined... the <assemblyIdentity>, which has the addin name and publickeytoken. I don't see "shadowCopyEnabled" anywhere. Can I add that attribute and set it to false, to see if that fixes things? Also, I'm opening the manifest file in a text editor, so please let me know if there's a better interface to work with it through visual studio.

Thanks!
Posted 25 Jan, 2007 14:50:04 Top
Jason Crabtree




Posts: 19
Joined: 2007-01-23
I did notice that if I create a c++ add-in project that doesn't use the ADX loader or a shim, then the Location property points to the right spot. However, I'm confused as to why my add-in started up fine and displayed a messagebox fine when I clicked the commandbar button, since I didn't use the loader or shim. I'm assuming that I'll eventually run into trouble if I don't use the loader or shim. I read the overview on loaders and shims in the support section, and it looks like I need one.
Posted 25 Jan, 2007 15:19:36 Top