MapWinGIS C#.Net Winform app without install

Sorry to ask an old question. A previous post asked how the VB program implements registration-free COM. The general idea is that by changing the settings in VS, VS will automatically generate a manifest file after compilation, and copy MapWinGIS OCX and all of its dependencies into your executable directory.
MapWinGis VB.Net without install
I am using the C# winform program, but I did not find the setting for the second step in the above post.
How do I set up the C# winform program? Thank you.
I am very sorry for asking for a question that has been answered before.

1 Like

Hello @Henry

In a c# app, the References are listed in the right-hand treeview rather than in the Project Properties. In there, you will find the Isolated property for both AxMapWinGIS and MapWinGIS. See below:

Regards,
Jerry.

Note that the project I have shown is not set up for Isolation; I just used it for the snapshot.

1 Like

awesome. After copying the debug folder to the client machine, without installing MapWinGIS, double-click the exe to run the program directly.

However, I also want to publish this program through ClickOnece, instead of letting customers copy a folder containing a lot of dlls. The specific operation is: in the VS development environment, right-click on the project and select publish. After the program is released, an installation package will be generated. The user double-clicks the installation package exe, the program will be installed on the machine. But after this operation, MapWinGIS cannot be packaged together. What should I do? Thank you.

Hello @jerryfaust

Can you help me again?

We don’t want users to copy a folder containing dlls. We want to publish the program and let users install the program (the specific operation is: by right-clicking the project in Visual Stidio and selecting “publish”).

So, how to publish a MapWinGIS-based program on the development machine, and the client machine can use the published program without installing MapWinGIS?

Best regards,
Henry.

Hello @Henry

I confess that I’ve never used the Publish feature, and don’t know exactly what it does. My best guess is that you would need all of the files to be seen as references (even though they are only run-time dependencies, and not build-time dependencies). I really don’t know.

I guess if you find or figure out an answer, you could post it here for others.

Regards,
Jerry.

Thank you for your patient answers. However, when referencing the dll in the C:\dev\MapWinGIS folder, an error will still be reported. Let me see if there are other solutions.

Best regards,
Henry.

It is not likely the Interop or the OCX, it is likely all of the other required files (GDAL, GEOS, etc.) that are stored in the MapWinGIS bin directory, but have to be in your applications bin directory in order to use registration-free COM.

Jerry.

1 Like

Hello @jerryfaust

Thank you for your answer.

I tried to follow your method and add dlls as references. First, I copy the dll in the C:\dev\MapWinGIS folder to the bin directory of the program. Then, I added a dll reference (dll in the bin folder) in Visual Studio. I encountered such an error, as shown in the picture below.

Therefore, I cannot reference these dlls as build-time dependencies. In fact, the essence of the latter problem is how to package the dlls for publishing.

Best regards,
Henry.

It seems that the problem can be solved by directly adding the dll to the project (instead of adding the dll in the reference). As shown below.

Best regards,
Henry.

1 Like

Excellent. Thank you, Henry, for sharing that. Glad you got it resolved.

Thank you for your selfless help.

Best regards,
Henry.

1 Like

Henry,

Having a very similar problem.

Can you tell me which dll(s) you directly added? Was it all of the ones in the MapWinGIS directory? Also the ones in the subdirectories of that directory?

Thanks!

Scott

Hello Scott,

If you have set the Isolated property in the project references (as described above in this thread) for MapWinGIS and AxMapWinGIS, your exe will be looking in it’s output bin directory for the OCX, and then the OCX will look in further subdirectories for GDAL data.

So I have always just copied the entire bin\Win32 contents of the OCX, including subfolders, to the bin directory of your exe. By including all of the DLLs in the project, the build process will effectively copy them to the output bin directory of your exe, but I think you will find that you need the GDAL subfolders as well.

Regards,
Jerry.

1 Like

Jerry,

I’ve isolated my problem a bit more. If I install MapWinGIS on a machine, my application works perfectly. If I don’t, I get some errors that appear to be coming from secondary calls from within MapWinGIS.

But here’s the interesting part. When I uninstall MapWinGIS - my code continues working properly on the target machine, even after a reboot.

So there is something in the MapWinGIS setup file that is probably adding something to the PATH variable, and that is what is allowing my app to then find the DLLs it needs.

Any idea what paths are added by the MapWinGIS install tool?

Thanks!

Scott

Hello Scott.

What about the MSVC runtime. If this was not present on the machine, then MapWinGIS will install it, and it is not uninstalled when you uninstall MapWinGIS.

You could verify this by first looking for the “Microsoft Visual C++ 2017 Redistributable (x86)” in the Programs and Features control panel. It likely does not exist on a typical machine.

See if that’s it. If it is, you just need to install the Redistributable as part of your setup.

Regards,
Jerry.

Hi all,

I just follow all instruction and find out the way to use registration-free COM.

  1. You need Microsoft Visual C++ Visual Studio 2017 (x86) installed on this PC. You can check this by your own code. You need x86 even if this PC run on x64 system. Follow this link to download.

  2. Add 3 new folders to your project: gdal-data, gdalplugins, PROJ_NAD (include Licenses if you want - It’s not required)

  1. Add everything on dev\MapWinGIS folder to your project corresponding

  2. Click on each item you added, change “Copy to output directory” to “Copy if newer”. You must ensure that “EVERY” items you added in MapWinGIS folder has changed to “Copy if newer”. The others of the project (like *.vb, your classes) is not required.

image

  1. Build your project or use Publish funtion and see the results.

I hope this will help you all.

1 Like

It a bit of an old post but for future reference, I also want to point to the setup file MapWindow5 is using.

MW5 is also using the isolated option and copies all MapWinGIS binaries, including the GDAL binaries to the output folder.
MW5 uses INNOSetup, which make it very easy and clear what is happening:

I’m closing this issue now.

1 Like