C# Clickonce Publishing DLL issues with gMap

0

I have an application that has been in use for a long time now. I recently added some new functionality including gMap. My application works great when I debug or build it out and test. The issue occurs when I publish as a clickonce and then install on my same machine. The app installs and when it tries to run I get the error "WMS Toolbox has stopped working". Looking at the event viewer I see that it is obviously missing dll files related to gMap.

--Event Viewer Fault1--


 Description: The process was terminated due to an unhandled exception.

 Exception Info: System.DllNotFoundException
    at System.Data.SQLite.UnsafeNativeMethods.sqlite3_libversion()
    at GMap.NET.CacheProviders.SQLitePureImageCache.Ping()
    at GMap.NET.GMaps.SQLitePing()
    at GMap.NET.WindowsForms.GMapControl..cctor()

 Exception Info: System.TypeInitializationException
    at GMap.NET.WindowsForms.GMapControl..ctor()
    at wmsToolBox.wmsToolBox.InitializeComponent()
    at wmsToolBox.wmsToolBox..ctor()
    at wmsToolBox.Program.Main()

--Event Viewer Fault2--


 Faulting application name: wmsToolBox.exe, version: 1.0.0.0, time stamp: 
 0x5d70eddb
 Faulting module name: KERNELBASE.dll, version: 10.0.15063.1836, time 
 stamp: 0xbb572fa7
 Exception code: 0xe0434352
 Fault offset: 0x000f18e2
 Faulting process id: 0x3a8
 Faulting application start time: 0x01d563db00e3051a
 Faulting module path: C:\windows\System32\KERNELBASE.dll
 Report Id: 0bc8cd8f-c137-4cd8-a8d8-880ce20add89
 Faulting package full name: 
 Faulting package-relative application ID: 

I have noted that this seems to be a know issue with applications dependent on sqlite.dlls.


Taking suggestions from other posts, here is what I have tried:

  • Removing all references from the application and adding them back, making sure they are all updated
  • I have tried creating x86 and x64 folders in my app and providing the SQLite.Interop.dll to both folders (This made no changes in the performance of the app)
  • I have downloaded the precompiled .net and then placed the System.Data.SQLite.dll near my exe (this caused install errors stating that the dll file already existed in the folder and wouldn't install)
  • I have tried adding dll files to the clickonce installation folder and running the app again. (this caused the following error:

    Exception Info: System.BadImageFormatException at GMap.NET.CacheProviders.SQLitePureImageCache.Ping() at GMap.NET.GMaps.SQLitePing() at GMap.NET.WindowsForms.GMapControl..cctor())

Sources I have referenced


How to Publish a Winforms App with SQLite using ClickOnce

I also referenced the suggestions at the following site. They are largely the same as the post on SO.

https://github.com/oysteinkrog/SQLite.Net-PCL/issues/158

c#
winforms
clickonce
asked on Stack Overflow Sep 5, 2019 by Konan

3 Answers

0

Unfortunately, I am having the same issue. I'm hoping you have a solution...

I have seen some of those solutions, but not tried any. One solution I found was to download the GMAP sources and compile it as an AnyCode version, but I don't know how to do that.

https://stackoverflow.com/a/43886479/4114838

answered on Stack Overflow Sep 18, 2019 by Elwood472
0

I have resolved this for myself using known solutions. I'll be specific since if it had been explained to me this way I would have gotten it done much quicker. It involves creating the x64 and x86 folders.

In Visual Studio, look at your Solution Explorer. Under the root of your project, add a folder for x64 and another for x86.

For each folder, right-click, select Add and then choose existing item. Add the file SQLite.Interop.dll to it. When you're done you MUST be able to see the folder and file in the Solution explorer.

In Solution Explorer, select the file SQLite.Interop.dll. In the properties, set Copy to Output Directory to "Copy if Newer". Do this for each folder (x86 and x64).

That's it. When you publish your project it should now work.

answered on Stack Overflow Sep 19, 2019 by Elwood472
0

I was finally able to resolve this issue. As elwood472 stated, it is very similar to the notes he provided. I have a few subtle additions to offer to be even more concise. This assumes that you have added the references to your application.

  1. Determine the target framework of your app, mine is 4.5.1
  2. Create the x86 and x64 folders in your project
  3. Navigate to the project folder solution/packages/System.Data.SQLite.Core.1.0.111.0/build/$target framework version$. You will see a x64 and x86 folder here, HOPEFULLY!
  4. Under the x64 folder, copy the SQLite.Interop.dll file to your project under the x64 folder
  5. Under the x86 folder, copy the SQLite.Interop.dll file to your project under the x86 folder
  6. Set the properties of both files to Build Action: content; Copy to output directory: Copy if newer

Publish the application and it finally worked for me. I think I had been getting incorrect framework versions by searching for the file. Elwood472 offered to use the directory: \Solution Name\packages\System.Data.SQLite.Core.1.0.111.0\lib\net46\ which can be incorrect per the framework you are building your app for. I'm not sure if there is a difference in the x86 and x64 files but I copied them to their respective folders and it worked fine.

If you have the wrong framework version you will likely get an error in Event Viewer that says Exception Info: System.BadImageFormatException

If you are missing the dll files all together you will likely get an error in Event Viewer that says Exception Info: System.DllNotFoundException

answered on Stack Overflow Sep 23, 2019 by Konan • edited Sep 30, 2019 by Konan

User contributions licensed under CC BY-SA 3.0