-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DuckDBConnection.Open Throwing 'The type initializer for 'DuckDB.NET.Data.DuckDBConnectionStringBuilder' threw an exception.' #241
Comments
What type of project are you building? Is it a Blazor app by any chance? |
Can you post the full exception? Including the InnerException. |
Exception Message = The type initializer for 'DuckDB.NET.Data.DuckDBConnectionStringBuilder' threw an exception. Exception StackTrace StackTrace = " at DuckDB.NET.Data.DuckDBConnectionStringBuilder.Parse(String connectionString) in //DuckDB.NET.Data/DuckDBConnectionStringBuilder.cs:line 68\r\n at DuckDB.NET.Data.DuckDBConnection.get_ParsedConnection() in //DuckDB.NET.Data/DuckDBConnection.cs:lin... Exception Source = "DuckDB.NET.Data" InnerException Message= {"Unable to load DLL 'duckdb': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"} InnerException StackTrace = " at DuckDB.NET.Native.NativeMethods.Configuration.DuckDBConfigCount()\r\n at DuckDB.NET.Data.DuckDBConnectionStringBuilder..cctor() in /_/DuckDB.NET.Data/DuckDBConnectionStringBuilder.cs:line 25" InnerException Source = "DuckDB.NET.Bindings" It not being able to find the .dll is odd. |
Which version of .NET are you targeting? Did you download duckdb.dll from the official website by any chance? There were some similar issues posted in discord channel, did you check them? |
TargetFrameworkVersion > v4.8 Here's the references in my .csproj:
I downloaded the DuckDB-JDBC from Maven Repository a while ago for work on another project, but that would have been separate from the current .NET project. |
DuckDB.NET.Data and DuckDB.NET.Bindings do not contain the native duckdb.dll. You must download it manually from the official website and put it in the bin folder. Make sure that your project is x64 and download the correct duckdb.dll - there are x64 and arm builds for Windows. |
Apologies for the late response. I checked the official site and I don't see any downloads for a dll, would it be included in either the cli after I run the exe, or will I need to download the ODBC? |
You can download it from https://duckdb.org/docs/installation/?version=stable&environment=cplusplus&platform=win&download_method=direct&architecture=x86_64 or install DuckDB.NET.Data.Full and copy duckdb.dll manually from the runtimes folder. |
Thank you. Unfortunately it seems that the project's platform target is x86, the product is several years old so I doubt switching to x64 would be feasible anytime soon. It seems that DuckDB only supports x64 so I may be out of luck. |
That's right, DuckDB doesn't support x86. |
I've tried with the two different NuGet packages 'DuckDB.NET.Data.Full' and 'DuckDB.NET.Bindings.Full'
When I attempt to open the DuckDB connection like so:
using (var connection = new DuckDBConnection("DataSource=:memory:")) { connection.Open(); ... }
I get the exception listed in the title:
The type initializer for 'DuckDB.NET.Data.DuckDBConnectionStringBuilder' threw an exception.
I've followed along in the debugger and here is where everything goes wrong in DuckDBConnection.cs
internal DuckDBConnectionString ParsedConnection => parsedConnection ??= DuckDBConnectionStringBuilder.Parse(ConnectionString);
ConnectionString is set to
DataSource=:memory:
I tried following a similar issue that's been closed out and didn't really resolve my issue. Is there any additional setup that I may be missing? I followed the documentation to the best of my ability .
The text was updated successfully, but these errors were encountered: