I am currently trying to deploy an Outlook VSTO Add In that I developed with Visual Studio. As long as I debug it with Visual Studio everything works perfectly fine. However, I ran into sume trouble as soon as I deployed it and installed it via the created .exe installer.
I pinned down the problem and it seems to be an additional .json file that the Add In opens and reads on start up. I created this file and store it in my Visual Studio Project Directory to save some data that the Add In needs.
I figured that the deployed and installed Add In might have difficulties finding the file as there might be a new filepath. So I tried the following:
- In the file properties set in Visual Studio I changed the settings to always copy the file to the output directory and build its content
- I changed the filepath from which the file is opened from just
"file.json"
toDim jsonFilePath As String = System.AppDomain.CurrentDomain.BaseDirectory + "file.json"
Both approaches did not work. So my question is if anyone has ideas on how I could fix that.
Many thanks in advance!
Update: Due to your ansers I figured it out. In VB.Net I now use:
Dim codebase As New System.Uri(Assembly.GetExecutingAssembly().CodeBase)
Dim filepath As String = Path.Combine(codebase.AbsolutePath, "..", "file.json")