Hello,
I am currently struggling to call a method from loaded .dll assembly. Assembly is a part of WinMapGIS and Map Window open source projects for manipulation of GIS data.
The issues is that, I can call any property or method which does not take any arguments.
But once a method requires at least one argument, an error message appears:
Could not convert argument 0 for call to Open.
I am basically trying to replicate the C# code which opens a .shp file:
using MapWinGIS;
string shpfilename = "C:/example.shp";
Shapefile sf = new Shapefile();
sf.Open(shpfilename, null)
Here is the ironpython replication:
import clr
clr.AddReferenceToFileAndPath("C:/mapwindow_dlls/Interop.MapWinGIS.dll")
import MapWinGIS
sf = MapWinGIS.ShapefileClass()
shpfilename = "C:/example.shp"
sf.Open(shpfilename, None) # raises the error message
On the last line, an upper error message appears (Could not convert argument 0 for call to Open).
Here is the signature of the “Open” method:
Open(self: ShapefileClass, ShapefileName: str, cBack: Callback) -> bool
// MapWinGIS.ShapefileClass
[DispId(11)] [MethodImpl(MethodImplOptions.InternalCall)] public virtual
extern bool Open([MarshalAs(UnmanagedType.BStr)] [In] string
ShapefileName, [MarshalAs(UnmanagedType.Interface)] [In] ICallback cBack
= null);
Just to make it clear: In upper C# example the Shapefile
class is used, while I used ShapefileClass
class. The reason is that, Shapefile
class does not contain Open
method. When I even try to instantiate it:
sf = MapWinGIS.Shapefile() # raises an error
It raises an error:
Cannot create instances of Shapefile because it is abstract
Looks like ShapefileClass
is an implementing class.
I did a little bit of search and the same thing happens at ironruby.
Author of this question states that the issue might be with the type of argument, supplied to the “Open” method (shpfilename
in this case).
I tried seeking for help on both ironpython mailing list, stackoverflow, and by contacting the developer of the MapWinGIS / Map Window projects. But without success.
Here are all the necessary .dll files (the upper mapwindow_dlls
folder) along with example.shp
file (.zip file is 27MB in size).
I would be very grateful for any kind of help.