Spatial4n icon indicating copy to clipboard operation
Spatial4n copied to clipboard

Assembly Redirects for Spatial4n.Core.NTS 0.3 and NetTopologySuite 1.13

Open h0st1le opened this issue 10 years ago • 2 comments

I took your advice and looked into using an assembly redirect to get Spatial4n.Core.NTS 0.3.0.0 working with NetTopologySuite 1.13.2.0. The redirect is as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="NetTopologySuite"
          publicKeyToken="f580a05016ebada1"
          culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-1.13.2.0" newVersion="1.13.2.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
</configuration>

Unfortunately this solution does not work. The latest version of NetTopologySuite no longer is strong named. As such I don't see how I can redirect the versions. I enabled fusion in an attempt to get a detailed log of the failed binding, and noticed the following:

WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN

I thought of redirecting Spatial4n.Core.NTS but again if I compile from source, there is no strong name associated with the assembly, in addition it also retains the same version number. Maybe I'm attempting this is the wrong manner, ideas?

full fusion log:

[7/1/2014 3:42:20 PM] [ERROR] [Go2It.Program.ProcessUnhandled]
Unhandled
The type initializer for 'Spatial4n.Core.Context.Nts.NtsSpatialContext' threw an exception.
Inner: System.IO.FileLoadException: Could not load file or assembly 'NetTopologySuite, Version=1.13.2.0, Culture=neutral, PublicKeyToken=f580a05016ebada1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'NetTopologySuite, Version=1.13.2.0, Culture=neutral, PublicKeyToken=f580a05016ebada1' ---> System.IO.FileLoadException: Could not load file or assembly 'NetTopologySuite, Version=1.12.4448.22555, Culture=neutral, PublicKeyToken=f580a05016ebada1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'NetTopologySuite, Version=1.12.4448.22555, Culture=neutral, PublicKeyToken=f580a05016ebada1'

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  H:\Workspace\dotspatial-go2it\Build\Debug\Go2It.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = jpenka
LOG: DisplayName = NetTopologySuite, Version=1.12.4448.22555, Culture=neutral, PublicKeyToken=f580a05016ebada1
 (Fully-specified)
LOG: Appbase = file:///H:/Workspace/dotspatial-go2it/Build/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Spatial4n.Core.NTS, Version=0.3.0.0, Culture=neutral, PublicKeyToken=9f9456e1ca16d45e.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: H:\Workspace\dotspatial-go2it\Build\Debug\Go2It.vshost.exe.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.12.4448.22555 redirected to 1.13.2.0.
LOG: Post-policy reference: NetTopologySuite, Version=1.13.2.0, Culture=neutral, PublicKeyToken=f580a05016ebada1
LOG: Attempting download of new URL file:///H:/Workspace/dotspatial-go2it/Build/Debug/NetTopologySuite.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

at Spatial4n.Core.Context.Nts.NtsSpatialContext..ctor(Boolean geo)
at Spatial4n.Core.Context.Nts.NtsSpatialContext..cctor() in z:\Projects\Spatial4n\Spatial4n.Core\Context\Nts\NtsSpatialContext.cs:line 40

Stack trace:    at Go2It.AdminForm.GetDocuments(IndexObject[] iobjects) in H:\Workspace\dotspatial-go2it\src\AdminForm.cs:line 1634
at Go2It.AdminForm.btnCreateIndex_Click(Object sender, EventArgs e) in H:\Workspace\dotspatial-go2it\src\AdminForm.cs:line 1552
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

h0st1le avatar Jul 01 '14 21:07 h0st1le