Wednesday, February 27, 2008

VS 2008 and Visio AddIn Deployment Issues

I stumbled across an issue when I was working on a Visio AddIn Project in Microsoft Visual Studio 2008. It is very easy to create an AddIn for Microsoft Office Applications like Visio using the project templates available in Visual Studio (File > New > Project > Visual C# > Office > Visio 2007 Add-in). It becomes little tougher when we need to deploy this AddIn especially if it has multiple projects and data files. I went for ClickOnce deployment as it was easier as right clicking on the project and choosing 'Publish'. My AddIn had to read a data file while loading.

While installing this application on a client machine using ClickOnce, it never ask you for an installation path and it copies the files into two different folders with random names! Mine looked like this:

C:\Users\Administrator\AppData\Local\Apps\2.0\CA5NQ9ZB.N44\E6TLT686.69V\visi..vsto_11aeaa34550a68ee_0001.0000_14f3717c0aa57ea0
C:\Users\Administrator\AppData\Local\Apps\2.0\CA5NQ9ZB.N44\E6TLT686.69V\visi...dll_11aeaa34550a68ee_0001.0000_none_47ef10bd354219e1

And the frustrating thing is that all dlls gets copied to the first folder and the data files to the other. So my application never found the file it needed to load and I had no idea on how to solve this as the folder names kept changing randomly with every new deployment. I think these are some caching locations and the application dlls were not available anywhere else. Do anybody know what is happening here and what is the solution?

Finally I made my Deployment work by making the data file as an embedded resource (Properties > Build Action) and reading the data as below:

Stream resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(MyNamespace.MyClass.MyFile.xml");

TextReader tr = new StreamReader(resourceStream);

No comments:

Post a Comment