Loader exceptions triggered by Eto in R7

Question for the dev team (maybe @curtisw):

We’re using a GPU acceleration library (CUDAfy) that’s experiencing issues specific to the Rhino 7 runtime environment. Namely, when we try to access the library’s translator from an R7 context, we get a type initialization exception:

System.TypeInitializationException: The type initializer for 'Cudafy.Translator.CudafyTranslator' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Cudafy.Translator.CUDALanguage' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
   at Cudafy.Translator.CUDALanguage..cctor()
   --- End of inner exception stack trace ---
   at Cudafy.Translator.CUDALanguage..ctor(eLanguage language)
   at Cudafy.Translator.CudafyTranslator..cctor()
   --- End of inner exception stack trace ---
   at Cudafy.Translator.CudafyTranslator.set_Language(eLanguage value)

The loader exception (with binding logging) is as follows:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.WebView2.Wpf, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Web.WebView2.Wpf, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Web.WebView2.Wpf, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Rhino 7/System/
LOG: Initial PrivatePath = NULL
Calling assembly : Eto.Wpf, Version=2.6.0.0, Culture=neutral, PublicKeyToken=552281e97c755530.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\Rhino 7\System\Rhino.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Web.WebView2.Wpf, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e
LOG: Attempting download of new URL file:///C:/Program Files/Rhino 7/System/Microsoft.Web.WebView2.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Rhino 7/System/Microsoft.Web.WebView2.Wpf/Microsoft.Web.WebView2.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Rhino 7/System/Microsoft.Web.WebView2.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Rhino 7/System/Microsoft.Web.WebView2.Wpf/Microsoft.Web.WebView2.Wpf.EXE.

The exception does not occur when running the same code from Rhino 6, or from a standalone executable. Not entirely sure what Eto’s doing here, or why it’s stirring the WebView2 pot at runtime (AFAIK it’s not involved in R7). Any thoughts?

Cheers.
-Jon

Hey @sarg,

Eto optionally uses WebView2 on Windows, which we do not include in Rhino 7 (for compatibility reasons). Thus, some of its types can not be loaded. It appears that the CUDALanguage goes through all loaded assemblies and tries to load all types, which it really should be handling any exceptions there as not all types can be loaded. Perhaps something like this.

Ideally CUDAfy should be updated but it appears that it has been archived. It wouldn’t be too difficult to make those changes, however.

Hope this helps!

1 Like

Ah okay, makes sense about Eto. Indeed CUDAfy is a dinosaur, but still surprisingly useful – perhaps a quick fix / recompile is in order. Thanks @curtisw

1 Like

That worked :+1:

1 Like