curiosity-ai / rocksdb-sharp

.net bindings for the rocksdb by facebook
BSD 2-Clause "Simplified" License
155 stars 38 forks source link

[Feature request] Single-file publication support #12

Closed nsentinel closed 2 years ago

nsentinel commented 2 years ago

It would be nice to have support for the single-file publication (.NET 5+).

Currently, library throws the exception:

System.TypeInitializationException The type initializer for 'RocksDbSharp.Native' threw an exception. 
Void .ctor()
   at RocksDbSharp.OptionsHandle..ctor()
   at RocksDbSharp.ColumnFamilyOptions..ctor()
   at RocksDbSharp.DbOptions..ctor()

NotSupportedException CodeBase is not supported on assemblies loaded from a single-file bundle. 
System.String get_CodeBase()

Initializer here: https://github.com/curiosity-ai/rocksdb-sharp/blob/ef23652f005c60bed6c73d44d2c5b12ff2842ab6/csharp/src/AutoNativeImport.cs#L375

can use AppContext.BaseDirectory and wrap CodeBase lines to try-catch clause to prevent it.

publish command:

dotnet publish -c Release --runtime win-x64 -p:PublishSingleFile=true -p:DebugType=embedded --self-contained true

Thanks in advance.

nsentinel commented 2 years ago

Seems it already implemented with this PR: https://github.com/curiosity-ai/rocksdb-sharp/pull/7

theolivenbaum commented 2 years ago

I've merged #7 but from reading the error, I think it won't fix this issue. I'll push another change for it