start postgissample get errror

Topics: WinForms Controls
Editor
Jan 11, 2012 at 9:53 AM

Hi!

I get this error when connecting to the PostGIS database using shapmap.dll

System.IO.FileLoadException was unhandled
  Message="Could not load file or assembly 'Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
  Source="SharpMap.Extensions"
  FileName="Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
  FusionLog="=== Pre-bind state information ===\r\nLOG: User = VIETNN-TMS-PC\\Administrator\r\nLOG: DisplayName = Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio 2008/Projects/EVNiTMaps/EVNiTMaps/bin/Debug/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : SharpMap.Extensions, Version=0.9.3575.26260, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: No application configuration file found.\r\nLOG: Using machine configuration file from C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Post-policy reference: Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7\r\nLOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio 2008/Projects/EVNiTMaps/EVNiTMaps/bin/Debug/Npgsql.DLL.\r\nWRN: Comparing the assembly name resulted in the mismatch: Major Version\r\nERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.\r\n"
  StackTrace:
       at SharpMap.Data.Providers.PostGIS.GetGeometryColumn()
       at SharpMap.Data.Providers.PostGIS..ctor(String ConnectionStr, String tablename, String OID_ColumnName) in D:\Dev\OpenSource\SharpMapV1\Trunk\SharpMap.Extensions\Data\Providers\PostGIS.cs:line 82
       at EVNiTMaps.clsPostGisDB.InitializeMap() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EVNiTMaps\EVNiTMaps\clsPostGisDB.cs:line 25
       at EVNiTMaps.Form1.AddLayerPostgis() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EVNiTMaps\EVNiTMaps\Form1.cs:line 151
       at EVNiTMaps.Form1.AddLayertoolStripButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EVNiTMaps\EVNiTMaps\Form1.cs:line 158
       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at EVNiTMaps.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EVNiTMaps\EVNiTMaps\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

help me plz.

Coordinator
Jan 11, 2012 at 10:35 AM

your are at least missing the reference to Npgsql (v2.0.11). You can get it using NuGet (http://nuget.org/packages/Npgsql).

btw, Where did you take the SharpMap.dll from?

FObermaier

Editor
Jan 12, 2012 at 3:07 AM

I get the dll from the source: http://sharpmap.codeplex.com/SourceControl/changeset/changes/69089

and i use Npgsql dll (v2.0.11.92) . I try to using postgis/postgres 9.x and throws this exception.

Coordinator
Jan 12, 2012 at 8:21 AM

Does the postgis sample of the winformsamples project work?

I assume that you reference/load the wrong npgsql dll somewhere along the line

Hth FObermaier