Closed statler closed 1 year ago
It works perfectly on local, but in MSI deployment, it fails with a nullreference exception when passed an empty string to init the context.
You need to elaborate on this and/or provide a repro.
Maybe you should use a fake but valid connection string instead?
Thanks - good idea - I will try that.
Did that resolve your issue?
I am assuming so
Hi ErikEJ,
I am using the https://www.nuget.org/packages/ErikEJ.EntityFramework.SqlServer library to add EF with Microsoft.Data.SqlClient. I use an app.config to configure. It works perfectly on local, but in MSI deployment, it fails with a nullreference exception when passed an empty string to init the context. This doesn't happen with 6.4.4 or Compact. This case arises because I have common form inits from pre and post login which is where the user selects the database connection. Ideas?
System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Microsoft.Data.SqlClient StackTrace: at Microsoft.Data.SqlClient.SqlConnection.get_ConnectionString() at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<>c.b__7_0(DbConnection t, DbConnectionInterceptionContext
1 c) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action
3 executing, Action`3 executed) at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.GetConnectionString(DbConnection connection, DbInterceptionContext interceptionContext) at System.Data.Entity.Internal.InternalConnection.GetStoreConnectionString(DbConnection connection) at System.Data.Entity.Internal.InternalConnection.OnConnectionInitialized() at System.Data.Entity.Internal.EagerInternalConnection..ctor(DbContext context, DbConnection existingConnection, Boolean connectionOwned) at System.Data.Entity.DbContext..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) at cpORM.Contexts.cpContext_base..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) in C:\Users\dennisg\source\repos\CivilProv9\cpDataORM\Contexts\cpContext_base.cs:line 182 at cpORM.Contexts.cpContext_MsSql..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) in C:\Users\dennisg\source\repos\CivilProv9\cpDataORM\Contexts\cpContext_base.cs:line 72 at cpORM.Contexts.Single.cpContextAll..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) in C:\Users\dennisg\source\repos\CivilProv9\cpDataORM\Contexts\Single\cpContextAll.cs:line 296 at cpORM.Helpers.Connection.GetNewEFContext() in C:\Users\dennisg\source\repos\CivilProv9\cpDataORM\Helpers\Connection.cs:line 42 at cpServices.Services.PermissionService..ctor() in C:\Users\dennisg\source\repos\CivilProv9\cpDataController\Services\PermissionService.cs:line 41 at CivilPro.UI.WinForms.ControlsEf.cpForm_common..ctor() in C:\Users\dennisg\source\repos\CivilProv9\CivilPro.UI.Winforms\ControlsEf\cpForm_common.cs:line 175 at CivilPro.UI.WinForms.Controls.CpXpoForm_base..ctor() in C:\Users\dennisg\source\repos\CivilProv9\CivilPro.UI.Winforms\Controls\CPForms\CpXpoForm_base.cs:line 54 at CivilPro.UI.WinForms.Controls.CpXpoForm_pop..ctor() at CivilPro.UI.WinForms.popLogin..ctor() in C:\Users\dennisg\source\repos\CivilProv9\CivilPro.UI.Winforms\SystemCP\Connection\popLogin.cs:line 50 at CivilPro.UI.WinForms.mdimProject.ShowLogon() in C:\Users\dennisg\source\repos\CivilProv9\CivilPro.UI.Winforms\mdimProject.cs:line 477 at CivilPro.UI.WinForms.mdimProject.mdimProject_Load(Object sender, EventArgs e) in C:\Users\dennisg\source\repos\CivilProv9\CivilPro.UI.Winforms\mdimProject.cs:line 454This exception was originally thrown at this call stack: [External Code] cpORM.Contexts.cpContext_base.cpContext_base(System.Data.Common.DbConnection, bool) in cpContext_base.cs cpORM.Contexts.cpContext_MsSql.cpContext_MsSql(System.Data.Common.DbConnection, bool) in cpContext_base.cs cpORM.Contexts.Single.cpContextAll.cpContextAll(System.Data.Common.DbConnection, bool) in cpContextAll.cs cpORM.Helpers.Connection.GetNewEFContext() in Connection.cs cpServices.Services.PermissionService.PermissionService() in PermissionService.cs CivilPro.UI.WinForms.ControlsEf.cpForm_common.cpForm_common() in cpForm_common.cs CivilPro.UI.WinForms.Controls.CpXpoForm_base.CpXpoForm_base() in CpXpoForm_base.cs [External Code] CivilPro.UI.WinForms.popLogin.popLogin() in popLogin.cs ... [Call Stack Truncated]