I am trying to pack my app in a single file, but I keep getting this exception that kills my exe:
Value cannot be null. (Parameter 'path1')
System.Private.CoreLib
at System.IO.Path.Combine(String path1, String path2)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
at OrderManager.Program.Main() in C:\Users\Documents\GitHub\OrderManager\Program.cs:line 52
Which is nothing fancy:
51. File.AppendAllText(AppContext.BaseDirectory + @"\log.txt", ProgramParameters.connectionStringAdmin + Environment.NewLine);
52. connection = new(ProgramParameters.connectionStringAdmin);
I check for the content of ProgramParameters.connectionStringAdmin
which is correct:
Data Source = C:\Users\Documents\GitHub\OrderManager\bin\Release\net6.0-windows10.0.22621.0\publish\db\ManagerOrdini.db ; cache=shared; synchronous = NORMAL ; journal_mode=WAL; temp_store = memory; mmap_size = 30000000000;
Debug
and Release
modes work as intended with no error.
My trial, beside some code testing, was to exclude the package from the .csproj file, but apparently it doesn’t extend to packages:
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
<OutputType>WinExe</OutputType>
<EmbedInteropTypes>True</EmbedInteropTypes>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>
<CustomResourceTypesSupport>true</CustomResourceTypesSupport>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<IsWebBootstrapper>false</IsWebBootstrapper>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<DebuggerSupport>true</DebuggerSupport>
<DebugType>embedded</DebugType>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
...
<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.118">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</PackageReference>
...
Any other suggestion?