0
votes

I try to write a makro for RegioGraph (regiograph.de). I have almost no knowledge of .NET. There is a help file from RegioGraph describing the API itself, but there is very limited information on how to use it. The only useful reference I found is this sample in C#: http://www.cgo.se/wordpress/2010/10/14/regiograph-api/.

updated 2013-12-11 after following advices from comments:

I found out the RegioGraph assembly is .NET 2.0, so I installed corresponding IronPython-2.6.2-Net20.msi: http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=ironpython&DownloadId=159513&FileTime=129321579152370000&Build=20841

I want to get an Application object:

IronPython 2.6.2 (2.6.10920.0) on .NET 2.0.50727.7905
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReferenceToFileAndPath('C:/Program Files/GfK GeoMarketing/RegioGraph Planung 11/GfK.GeoMarketing.Api.dll')
>>> import GfK.GeoMarketing.Api
>>> app = GfK.GeoMarketing.Api.RegioApplication()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] Die Datei oder Assembly "GfK.GeoMarketing.Api, Version=11.0.0.96, Culture=neutral, PublicKeyToken=49e059cfaef07841" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

Examination with Fusion protocol shows that the assembly is searched only in the global assembly cache (GAC) and in the IronPython program folder. So a workaround is to copy GfK*.dll into C:/Program Files/IronPython 2.6/.

When I installed Visual Studio Express 2013 Desktop I got this short C# program to work:

using GfK.GeoMarketing.Api;

class RGStart
{
    static void Main()
    {
        RegioApplication application = new RegioApplication();
    }
}

I had to follow these steps (trying to translate german terms):

  • new project, installed/templates/Visual C#/Windows/console application, name: RGStart
  • project, RGStart properties, application, target framework .NET 2.0
  • project, RGStart properties, make/build, target platform x86
  • delete invalid references (marked in project map explorer)
  • project, add reference, browse, C:\Program Files\GfK GeoMarketing\RegioGraph Planung 11
    • GfK.GeoMarketing.Api.dll
    • GfK.GeoMarketing.Gui.dll
    • GfK.GeoMarketing.ManagedBackend.dll
  • replace C# code (Program.cs)
  • F5, no more error messages, the application object enables access to RegioGraph
1
Can you translate the first error message to English? It looks like it can't load an assembly, but I'm not sure. - Jeff Hardy
@JeffHardy: Could not load file or assembly "GfK.GeoMarketing.Api, Version=11.0.0.96, Culture=neutral, PublicKeyToken=49e059cfaef07841" or one of its dependencies. The system cannot find the file specified. - Redoute
Try calling clr.AddReference on all of the GfK.GeoMarketing.* assemblies before doing anything else - I'm guessing it's having trouble loading one of them but the exception isn't clear about why. Otherwise you'll need to look into enabling Fusion logging and using fuslogvw.exe to figure out what the loading issue is. - Jeff Hardy
@JeffHardy Please excuse my slow responses. I got my current RegioGraph problem solved by writing a plugin with C#, and then moved on to other tasks. - Redoute
@JeffHardy As I learned about different .NET frameworks, today I replaced IronPython with an older version with .NET 2 instead. Not sure if this was necessary, as I got the same results as before. Then I managed to follow your hint about Fusion Logging, which showed assembler binder looks only in GAC and in IronPython folder. After copying GfK.* into C:\Program Files\IronPython 2.6 I get an application object (same commands as above). Don't want to post this as solution, as there sure is a better way (install files in GAC?). - Redoute

1 Answers

0
votes

Prerequisites: The tool gacutil.exe is from Microsofts "NETFX 4.5.1 Tools"; fuslogvw.exe and ildasm.exe may be useful too. These are part of Windows SDK, which I think was part of "Visual Studio Express 2013 for Windows Desktop" installation.

  1. Add the RegioGraph API assemblies to the global assembly cache (GAC):

    gacutil /i C:\Program Files\GfK GeoMarketing\RegioGraph Planung 11\GfK.GeoMarketing.Api.dll
    

    Ditto at least for .Shared, .Interfaces, .ManagedBackend, .LowLevelBackend, .Projections. It is probably best to install all GfK.*.dll into GAC.

  2. Use the following commands in IronPython Console:

    import clr
    clr.AddReference('GfK.GeoMarketing.Api')
    import GfK.GeoMarketing.Api
    app = GfK.GeoMarketing.Api.RegioApplication()
    proj = app.OpenProject('path\\to\\.gfk\\file')
    # ... yeah, got it! ...
    

    Experimenting with C# in Visual Studio, the RegioGraph API seemed to be bound to .NET 2.0. However, this instruction works with current IronPython (2.7.4 on .NET 4.0) as well as with an ancient .NET 2.0-IronPython.