Shapefile is an interface with a CoClassAttribute to ShapefileClass (which
means when you do new Shapefile() in C# it creates an instance of
ShapefileClass). I have no idea what the correct behaviour for IronPython
should be, but in this case MapWinGIS.Shapefile gives you the interface.

You could try MapWinGIS.ShapefileClass() instead of MapWinGIS.Shapefile().



On Mon, Jan 25, 2016 at 11:03 AM, Djordje Spasic via Ironpython-users <
ironpython-users@python.org> wrote:

> Hello,
>
> I am trying to call a specific method ("Open") from the .NET assembly.
> The .NET assembly along with all other .dlls and necessary files, can be
> downloaded from here
> <https://mapwindow4.codeplex.com/releases/view/110244>. It's free an open
> source project: MapWindow.
>
> In their examples page
> <http://www.mapwindow.org/documentation/mapwingis4.9/examples.html>, by
> loading the *Interop.MapWinGIS.dll* file, they call the *MapWinGIS.*
> *Shapefile.Open()* method like so:
>
> using MapWinGIS;
>
> string shpfilename = "C:/example.shp";
> Shapefile sf = new Shapefile();
> if (sf.*Open*(shpfilename, null))
> {
> }
>
>
> However, when I try the same thing in ironpython:
>
>     import clr
>     import os
>
>     shpfilename = "C:/example.shp"
>     dllsfilename = "C:/mapwindow_dlls"
>
>     clr.AddReferenceToFileAndPath(os.path.join(dllsfilename,
> "Interop.MapWinGIS.dll"))
>     print "Interop.MapWinGIS.dll loaded: ", "Interop.MapWinGIS" in
> [assembly.GetName().Name for assembly in clr.References]  # prints: True
>     import MapWinGIS
>
>     sf = MapWinGIS.Shapefile()  # raises Error
>     sf.*Open*(shpfilename, None)
>
>
> I am getting an error message:
>
> *   "Message: Cannot create instances of Shapefile because it is abstract"*
>
> Why is this happening?
>
> I contacted the author of the project, but couldn't solve the issue.
>
> Any kind of advice would be helpful.
>
> Kind regards,
> Djordje Spasic
>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users@python.org
> https://mail.python.org/mailman/listinfo/ironpython-users
>
>
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to