morrisjdev / FileContextCore

FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Apache License 2.0
169 stars 45 forks source link

Exception in EXCELStoreManager #27

Closed pillepalle1 closed 4 years ago

pillepalle1 commented 4 years ago

I am following the introduction of the Entity Framework Introduction here: https://docs.microsoft.com/en-us/ef/core/get-started/?tabs=netcore-cli . The project works fine when using JSONStoreManager. If however I change the line

protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options.UseFileContextDatabase();

to

protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options.UseFileContextDatabase<EXCELStoreManager>();

then I receive the following Exception

Unhandled exception. System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
   at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
   at System.Drawing.SafeNativeMethods.Gdip..cctor()
   --- End of inner exception stack trace ---
   at System.Drawing.SafeNativeMethods.Gdip.GdipGetGenericFontFamilySansSerif(IntPtr& fontfamily)
   at System.Drawing.FontFamily.GetGdipGenericSansSerif()
   at System.Drawing.FontFamily.get_GenericSansSerif()
   at System.Drawing.Font.CreateFont(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical)
   at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
   at OfficeOpenXml.ExcelRangeBase.AutoFitColumns(Double MinimumWidth, Double MaximumWidth)
   at OfficeOpenXml.ExcelRangeBase.AutoFitColumns(Double MinimumWidth)
   at OfficeOpenXml.ExcelRangeBase.AutoFitColumns()
   at OfficeOpenXml.ExcelColumn.AutoFit()
   at FileContextCore.StoreManager.EXCELStoreManager.Initialize(IFileContextScopedOptions options, IEntityType entityType, Object keyValueFactory)
   at FileContextCore.Storage.Internal.FileContextTable`1.Init()
   at FileContextCore.Storage.Internal.FileContextTable`1..ctor(IPrincipalKeyValueFactory`1 keyValueFactory, Boolean sensitiveLoggingEnabled, IEntityType entityType, IFileContextScopedOptions options, IServiceProvider serviceProvider)
   at FileContextCore.Storage.Internal.FileContextTableFactory.<>c__DisplayClass7_0`1.<CreateFactory>b__0()
   at FileContextCore.Storage.Internal.FileContextTableFactory.Create(IEntityType entityType)
   at FileContextCore.Storage.Internal.FileContextStore.EnsureTable(Object key, IEntityType entityType)
   at FileContextCore.Storage.Internal.FileContextStore.GetIntegerValueGenerator[TProperty](IProperty property)
   at FileContextCore.ValueGeneration.Internal.FileContextValueGeneratorSelector.GetOrCreate(IProperty property)
   at FileContextCore.ValueGeneration.Internal.FileContextValueGeneratorSelector.Select(IProperty property, IEntityType entityType)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ValueGenerationManager.Generate(InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges, Boolean modifyProperties, Nullable`1 forceStateWhenUnknownKey)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode`1 node)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState targetState, EntityState storeGeneratedWithKeySetTargetState, Boolean forceStateWhenUnknownKey)
   at Microsoft.EntityFrameworkCore.DbContext.SetEntityState(InternalEntityEntry entry, EntityState entityState)
   at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity](TEntity entity, EntityState entityState)
   at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity](TEntity entity)
   at dotnet_dev.Program.Main() in /home/benj/clients/agentjs/src/backend/dotnet-dev/Program.cs:line 14

Environment

$ dotnet --version
3.1.302

$ uname -a
Linux 5.4.52-1-lts #1 SMP Thu, 16 Jul 2020 19:35:06 +0000 x86_64 GNU/Linux
morrisjdev commented 4 years ago

Did you follow the readme and installed libgdiplus?

https://github.com/morrisjdev/FileContextCore#excelserializer

pillepalle1 commented 4 years ago

Missed that step. Works like a charm.