Subscribe to this thread
Home - General / All posts - System.Memory and dll loading
rk
539 post(s)
#01-Apr-22 10:42

I figured something out. I tried IronPython 3.4.0 and got error of not being able to load System.Memory v4.0.1.1

System.Memory.dll comes with and is placed right next to Ironpython.dll in manifold/shared.

Using Process Monitor (Tools -> File summary) I could see that manifold process looks for System.Memory from following locations but not where Ironpython.dll, which requires it, is.

C:\Program Files\Manifold\v9.0\bin64\System.Memory.dll

C:\Program Files\Manifold\v9.0\bin64\System.Memory.exe

C:\Program Files\Manifold\v9.0\bin64\System.Memory

C:\Program Files\Manifold\v9.0\Bin64\System.Memory\System.Memory.dll

C:\Program Files\Manifold\v9.0\Bin64\System.Memory\System.Memory.exe

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

C:\Windows\assembly\GAC_MSIL\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

C:\Windows\Microsoft.Net\assembly\GAC\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

C:\Windows\Microsoft.Net\assembly\GAC_64\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

C:\Windows\assembly\GAC\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

C:\Windows\assembly\GAC_64\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll

Workaround is to copy System.Memory to bin64.

I know from previous experience that I can put gdal.dll in any subfolder to bin64, but plugins for gdal MUST be at bin64\gdalplugins. Otherwise manifold process does not find them. Usually gdalplugins folder is relative to gdal.dll.

This looks like "current directory" or "relative path" issue.

I could probably install System.Memory into GAC but I read there are some issues(*). I do not understand if I should avoid GAC or just use it and not worry.

(*)

https://github.com/dotnet/msbuild/pull/6470

https://github.com/dotnet/runtime/issues/45921

adamw


10,126 post(s)
#04-Apr-22 08:16

That looks like the standard binding process done by Fusion (part of .NET).

What exactly is the dependency on System.Memory.dll - I take it you have an assembly that is referencing it (has been compiled with a reference to it), right? How are you loading that assembly? Dynamically through reflection? Through $reference$ in a script? Or somehow differently?

In general, we can control the binding process and make it go through ~/shared, ~/binXX/*, etc.

GAC is generally best avoided, used as a last resort (because if everyone starts using it, the result is a mess with new and new things having to go into GAC and multiple versions of the same DLLs staying there forever).

rk
539 post(s)
#04-Apr-22 09:14

Ironpython 3.4-beta requires System.Memory. (2.7.x do not.)

3.4 includes 3 new dlls compared to 2.7.x

shared\IronPython\IronPython.dll

shared\IronPython\IronPython.Modules.dll

shared\IronPython\Microsoft.Dynamic.dll

shared\IronPython\Microsoft.Scripting.dll

shared\IronPython\System.Buffers.dll

shared\IronPython\System.Memory.dll

shared\IronPython\System.Runtime.CompilerServices.Unsafe.dll

shared\IronPython\DLLs\IronPython.SQLite.dll

shared\IronPython\DLLs\IronPython.Wpf.dll

I just open New Command Window -> Ironptyhon

Simple 2+2 works. Other things not, if I remove System.Memory from bin64.

> 245725674562435*2457245724562435

Exception has been thrown by the target of an invocation.

 Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

> 2+2

4

rk
539 post(s)
#26-Jul-22 19:17

With changes in 9.0.177.2, System.Memory.dll is now found.

ProcessMonitor events:

C:\Windows\Microsoft.Net\assembly\GAC_64\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll                 PATH NOT FOUND

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll               PATH NOT FOUND

C:\Windows\Microsoft.Net\assembly\GAC\System.Memory\v4.0_4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll                    PATH NOT FOUND

C:\Windows\assembly\GAC_64\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll                                    PATH NOT FOUND

C:\Windows\assembly\GAC_MSIL\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll                                  PATH NOT FOUND

C:\Windows\assembly\GAC\System.Memory\4.0.1.1__cc7b13ffcd2ddd51\System.Memory.dll                                       PATH NOT FOUND

D:\Manifold-9-Edge\System.Memory.dll                                                                                    NAME NOT FOUND

D:\Manifold-9-Edge\System.Memory\System.Memory.dll                                                                      PATH NOT FOUND

D:\Manifold-9-Edge\extras\IronPython\System.Memory.dll                                                                  SUCCESS

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.