Error when view DGN (dear FObermaier)

Topics: SharpMap v0.9 / v1.x
Nov 10, 2011 at 1:57 AM

Dear FObermaier

I have code read file DGN:

   MapControl = new SharpMap.Map(mapImage.Size);

        
            SharpMap.Layers.VectorLayer DgnLayer = new SharpMap.Layers.VectorLayer("DGN");          //1
  
            SharpMap.Data.Providers.Ogr provider = new SharpMap.Data.Providers.Ogr(filename);  //2
     
            DgnLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(HandlerClass.ReadFromDgnFile(provider));  //3

 

When debug then error;

the type initializer for sharpmap.data.providers.ogr threw an exception

I think it error code at row 1?

I using sharmap 0.9.4015.17150 and Win7 home premium x64

You can check above my code .

I very need it.

Thanks you very much.

Coordinator
Nov 10, 2011 at 8:16 AM

You need to make sure that your application targets x86 platform. The Ogr C# bindings used within SharpMap require that.

Please also look at this.

Hth FObermaier

Nov 10, 2011 at 8:35 AM

Dear FObermaier

I debuged application in x86 platform and add

<configuration>

<appSettings>
   
    <add key="FWToolsBinPath" value="C:\FWTools2.4.7\bin"/>
    <add key="FWToolsProjLib" value="C:\FWTools2.4.7\proj_lib"/>
    <add key="FWToolsGeoTiffCsv" value="C:\FWTools2.4.7\data"/>
    <add key="FWToolsGdalData" value="C:\FWTools2.4.7\data"/>
   
  </appSettings>

</configuration>

but error the type initializer for sharpmap.data.providers.ogr threw an exception ?

Help me, please!

tks

Coordinator
Nov 10, 2011 at 9:38 AM

Please provide

  • full stack trace:
  • Environment variables set (result of cmd.exe -> set > environmet.txt)
Nov 10, 2011 at 10:02 AM

Dear FObermaier

1/ full stack trace: I don't undertand, you can explained (how I do)

2/ I send Environment variables set on my computer

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Admin\AppData\Roaming
ARCGISHOME=C:\Program Files (x86)\ArcGIS\
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=HTTECH
ComSpec=C:\windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Admin
IVSHOME7=C:\Program Files\IVS7
lib=C:\Program Files\SQLXML 4.0\bin\
LOCALAPPDATA=C:\Users\Admin\AppData\Local
LOGONSERVER=\\HTTECH
NUMBER_OF_PROCESSORS=4
OnlineServices=Online Services
OS=Windows_NT
Path=C:\Program Files (x86)\Common Files\TEC-IT\TBarCode\10.2\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\Services\IPT\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\ArcGIS\ArcSDE\sqlexe\bin;C:\AppServ\Apache2.2\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PCBRAND=s
Platform=BNB
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\windows\system32\WindowsPowerShell\v1.0\Modules\
PTSMInstallPath_X86=c:\Program Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\
PUBLIC=C:\Users\Public
PYTHONPATH=C:\Program Files (x86)\ArcGIS\bin
SDEHOME=C:\Program Files (x86)\ArcGIS\ArcSDE\sqlexe\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\windows
TEMP=C:\Users\Admin\AppData\Local\Temp
TMP=C:\Users\Admin\AppData\Local\Temp
USERDOMAIN=HTTECH
USERNAME=Admin
USERPROFILE=C:\Users\Admin
VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\
windir=C:\windows

Tks

Coordinator
Nov 10, 2011 at 12:57 PM

For full stack trace look at the output pane or view details when the exception is thrown.

Nov 11, 2011 at 4:22 AM

Dear FObermaier

"For full stack trace look at the output pane or view details when the exception is thrown."

this error when run create unit test: the following error was encountered while reading module sharpmap assembly reference not resolved brutile, version= 0.4.0.0 culture=neutral, publickeyToken=null

You can see again.

Tks.

 

Coordinator
Nov 11, 2011 at 7:21 AM

Do yourself a favor and compile SharpMap solution yourself and do not rely on provided binaries.

Hth FObermaier

Nov 11, 2011 at 9:36 AM

Dear FObermaier

I send you view details when the exception is thrown

System.TypeInitializationException was unhandled
Message: The type initializer for 'SharpMap.Data.Providers.Ogr' threw an exception.

and file contain variable set above:

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Admin\AppData\Roaming
ARCGISHOME=C:\Program Files (x86)\ArcGIS\
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=HTTECH
ComSpec=C:\windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Admin
IVSHOME7=C:\Program Files\IVS7
lib=C:\Program Files\SQLXML 4.0\bin\
LOCALAPPDATA=C:\Users\Admin\AppData\Local
LOGONSERVER=\\HTTECH
NUMBER_OF_PROCESSORS=4
OnlineServices=Online Services
OS=Windows_NT
Path=C:\Program Files (x86)\Common Files\TEC-IT\TBarCode\10.2\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\Services\IPT\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\ArcGIS\ArcSDE\sqlexe\bin;C:\AppServ\Apache2.2\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PCBRAND=s
Platform=BNB
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\windows\system32\WindowsPowerShell\v1.0\Modules\
PTSMInstallPath_X86=c:\Program Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\
PUBLIC=C:\Users\Public
PYTHONPATH=C:\Program Files (x86)\ArcGIS\bin
SDEHOME=C:\Program Files (x86)\ArcGIS\ArcSDE\sqlexe\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\windows
TEMP=C:\Users\Admin\AppData\Local\Temp
TMP=C:\Users\Admin\AppData\Local\Temp
USERDOMAIN=HTTECH
USERNAME=Admin
USERPROFILE=C:\Users\Admin
VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\
windir=C:\windows

 

I check errors and only find above error to solve this problem " the type initializer for sharpmap.data.providers.ogr threw an exception" when i debug program for file DGN

Help me, please.

Tks FObermaier  for this support

 

Coordinator
Nov 11, 2011 at 10:12 AM

you have fwtools 2.4.7 installed to c:\FWTools2.4.7? Please veryfy with cmd -> tree c:\fwtools2.4.7.

If it is, then replace referenced ogr_csharp.dll, gdal_csharp.dll and osr_csharp.dll with the ones provided in c:\fwtools2.4.7\csharp

If it isn't install it to that location, or adjust your path.

Hth FObermaier

Nov 12, 2011 at 7:33 AM

Dear FObermaier

Now, I debug other error "Object reference not set to an instance of an object"

Please, help me.

Coordinator
Nov 14, 2011 at 7:15 AM

you need to be more specific if you want us to help you. It can be virtually anything.