Ionide-vscode-fsharp: System.TypeInitializationException

Created on 25 Jun 2019  路  26Comments  路  Source: ionide/ionide-vscode-fsharp

Describe the bug
Enabling Ionide-fsharp extension in VSC causes this error:

System.TypeInitializationException: Typeinitialiseringsfunktionen for 'Microsoft.Data.Sqlite.SqliteConnection' udl酶ste en undtagelse. ---> System.Reflection.TargetInvocationException: Destinationen for en aktivering udl酶ste en undtagelse. ---> System.DllNotFoundException: DLL'en 'e_sqlite3' kunne ikke indl忙ses: Det angivne modul blev ikke fundet. (Undtagelse fra HRESULT: 0x8007007E)
   ved SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()
   ved SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
   --- Slut p氓 staksporing af indre undtagelser ---
   ved System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   ved System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   ved System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   ved Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   ved Microsoft.Data.Sqlite.SqliteConnection..cctor()
   --- Slut p氓 staksporing af indre undtagelser ---
   ved Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
   ved SymbolCache.PersistenCacheImpl.initializeCache(String dir)
   ved FsAutoComplete.Commands.StartBackgroundService(FSharpOption`1 workspaceDir)
   ved [email protected](Unit unitVar)
   ved Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   ved Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)

To Reproduce
Steps to reproduce the behaviour:

  1. Disable the Ionide-fsharp extension in VSC
  2. Close VSC and restart VSC
  3. Enable the Ionide-fsharp extension in VSC
  4. See error above

Expected behaviour
No error

Environment (please complete the following information):

  • OS: Windows_NT x64 10.0.17134
  • Ionide version: 4.0.0
  • VSCode version:
    Version: 1.36.0-insider (system setup)
    Commit: e80dd4f217db6e230d311a87fdf4276f740f6445
    Date: 2019-06-25T05:19:01.461Z
    Electron: 4.2.5
    Chrome: 69.0.3497.128
    Node.js: 10.11.0
    V8: 6.9.427.31-electron.0

  • dotnet SDK version: 2.2.203

  • mono / .Net Framework version:
    Mono JIT compiler version 5.20.1 (Visual Studio built mono)

Additional context
Is this a Ionide-fsharp issue or a VSC issue ?
I have reported this issue to the VSC Github too.

bug language services workaround

Most helpful comment

I have been experiencing the issue as well. When I change the fsac runtime setting to netcore Ionide seems to be working fine within a certain file, but it doesn't work when trying to recognize problems errors because of changes made to other files.

All 26 comments

Hey @janpop2017 :wave:,

Thank you for opening an issue. We will get back to you as
soon as we can. Also, check out our OpenCollective and consider
backing us.

https://opencollective.com/ionide

PS.: We offer backer support for all backers. Don't forget to add backer label when you start backing us :smile:

I have been experiencing the same issue since yesterday. The error message disappears when I change fsac runtime to netcore instead of net in the settings, but I need net since netcore does not support the SQL type provider (as in #1026).

Edit: netcore seems to support SQL types currently, but as TPLeon als writes below, there is no file interaction unless you reload. So changes made in one file will not be picked up by Ionide in any other file unless you reload the window.

I have been experiencing the issue as well. When I change the fsac runtime setting to netcore Ionide seems to be working fine within a certain file, but it doesn't work when trying to recognize problems errors because of changes made to other files.

PS I am a backer, but I am new to bug reporting, so I don't know how to add a backer label to this issue.

The bot message is false, the label is placed automatically when you open an issue if your opencollective account is linked to your github

I'm having the exact same issue with ionide-fsharp 4.0.0 on Windows 10 x64 (net runtime).
It seems a consequence of that is the F# language server does not start (no "F# Language Service" output panel).
And autocompletion does not work...

Same issue using ionide-fsharp 4.0.0. FSI does not start, no autocomplete/intellisense. Following setup:

  • OS: Windows_NT x64 10.0.17134
  • VSC: 1.35.1 (edit also doesn't work with 1.34.0)

I'm having same issues on multiple computers...

This is the English version of the error:

System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()
   at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   at Microsoft.Data.Sqlite.SqliteConnection..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
   at SymbolCache.PersistenCacheImpl.initializeCache(String dir)
   at FsAutoComplete.Commands.StartBackgroundService(FSharpOption`1 workspaceDir)
   at [email protected](Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)

It crashes ionide totally and no command works.
Tried to add the path to e_sqlite3.dll or copy the dll in other locations but it doesn't help :(

Known workaround - use netcore FSAC runtime

@Krzysztof-Cieslak This workaround was already mentioned above. There was an issue with it thou: Interaction between files doesn't seem to be working except when reloading.

Can someone check that on 4.0.1 ?

Just did. Still no IntelliSense (.net), but it seems the exception has gone.

I think I am experiencing the same issue on a Windows 10 machine, using ionide 4.0.1 (fsac runtime: netcore) trying to compile a netcoreapp2.2 hello world. There is no intellisense or autocompletion. The only relevant log info I can find is in Output: F# which mostly says:

Request: textDocument/completion failed.
Message: no type check results
Code: -32603

It sometimes says:

Request: textDocument/completion failed.
Message: Cached typecheck results not yet available
Code: -32603

Note that I have a Linux machine and intellisense and autocompletion work fine on it.

Tell me if there is any more information I can provide that would help.

Can someone check that on 4.0.1 ?

The same error for 4.0.1 (W10).

Startup exception should be fixed in 4.0.4.

For any other problems (missing autocomplete etc) please create separate issue with detailed description and reproduction. Thanks.

I'm still seeing this on 4.0.4, unfortunately.

System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.DllNotFoundException: e_sqlite3
    at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a]
    in <6649516e5b3542319fb262b421af0adb>:0

I checked in the ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin folder and libe_sqlite3.dylib is there, so I don't know why the DllNotFoundException is happening. I also looked in ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin_forge and there was no libe_sqlite3.dylib file there, so perhaps that's the cause? Forge initialization, rather than Ionide initialization? No idea if that's correct, just guessing here.

Environment (please complete the following information):

  • OS version: Linux x64 4.15.0-20-generic (Linux Mint 19, based on Ubuntu 18.04)
  • Ionide version: 4.0.4
  • VSCode version: Code 1.36.0 (0f3794b38477eea13fb47fbe15a42798e6129338, 2019-07-03T13:20:56.241Z)
  • dotnet SDK version: 2.2.300
  • mono / .Net Framework version: Mono version 5.20.1.19

    System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz (12 x 3990)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: unavailable_off
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|1, 1, 1|
|Memory (System)|62.68GB (58.08GB free)|
|Process Argv|.|
|Screen Reader|no|
|VM|0%|

Forge is not using SQLite so it鈥檚 definite not it. I鈥檒l keep looking - I鈥檓 bit surprised, as it鈥檚 working just fine on my OSX

Wait... you use a Mac. That's why the .dylib file is working for you, but not for people on Linux or Windows: file ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin/libe_sqlite3.dylib shows that file as a "Mach-O universal binary", which is an OSX-specific format that Linux and Windows don't use. Linux expects a .so file (which can apparently be compiled with the -shared flag) and Windows expects a .dll file.

@rmunn, just for sake of testing - you can find .so file in ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin_netcore/runtimes/ under appropriate target subdirectories. Can you copy the file to the ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin ?

I'm not sure why the packaging and handling native libs is different for the dotnet publish on .Net Core and on Full Framework.

I have a laptop and a stationary PC:
A1 ) My Laptop PC has been upgraded to the latest version Windows 10 (1903) and I have upgraded to ionide-fsharp-4.0.4 and I do not get the System.TypeInitializationException error anymore (no matter which FSAC runtime I choose) - Great !
A2 ) If I use net as FSAC runtime, I do not get Codelens or Linelens
A3 ) I too have the file ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin/libe_sqlite3.dylib
(and no *.dll file)

B1 ) My stationary PC has been upgraded to the latest version Windows 10 (1903) and I have I (uninstalled / removed / cleaned / rebooted) the latest Ionide and VSC, so the settings are the default. Here I do not get the System.TypeInitializationException error no matter which FSAC runtime I use. Codelens or Linelens will not work (I get "No Options" everywhere).

  • This PC has leftovers from VS 2015 (but I have upgraded to VS 2019 on both machines).

@Krzysztof-Cieslak I copied libe_sqlite3.so from ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin/runtimes/linux-x64/native to ~/.vscode/extensions/ionide.ionide-fsharp-4.0.4/bin and that fixed this bug: with a .so file in the bin folder, everything works.

On Windows 10 x64 and version 4.0.4, I haven't got the TypeInitializationException any more.
But autocompletion is still not working with "net" FSAC.
However, since all seems to be working fine with "netcore" FSAC (including type providers), is it a big deal ?

@sbacquet, for me, everything seems to be working as well, except for the intellisense between different files. This is crucial when working on a big project!

As there are type providers that are not compatible with .Net Core (FsXaml.Wpf for instance), "netcore" FSAC reports errors.
So yes (answering to myself), having a working "net" FSAC is still a must for me (until .NET Core 3.0 is released).

Can we stay on topic here, thanks

For any other problems (missing autocomplete etc) please create separate issue with detailed description and reproduction. Thanks.

Startup exception should be fixed in 4.0.5.

For any other problems (missing autocomplete etc) please create separate issue with detailed description and reproduction. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  5Comments

landy picture landy  路  5Comments

yuhr picture yuhr  路  3Comments

cartermp picture cartermp  路  4Comments

MikaelUmaN picture MikaelUmaN  路  5Comments