VistaDb Entities and Datasource NullReference Exception

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!

I’m using Entities with VistaDB (embeded database from gibraltar sw), in Asp.Net Application.

My code is like:

var clientList = model.Clients.Select(x => new GymClient { LastName = x.LastName }).ToList();
dataGridView1.DataSource = clientList;

If I use next connection string, app throws error after set datasource in datagridview. Local database is in bin folder

static string ConnectionString => $”Data Source=\”{HttpRuntime.BinDirectory}\\{DatabaseFile}\”;Open Mode=NonExclusiveReadWrite;Password=\”{SensistiveEncriptionKey}\”;Pooling=true”;



en Wisej.Core.ComponentManager.SetDirty(IWisejComponent component)
en Wisej.Base.ControlBase.Wisej.Core.IWisejComponent.set_IsDirty(Boolean value)
en Wisej.Base.ControlBase.Update()
en Wisej.Web.DataGridView.Update()
en Wisej.Web.DataGridViewColumnCollection.Add(DataGridViewColumn column)
en Wisej.Web.DataGridView.AutoGenerateBoundColumns(DataGridViewColumn[] newBoundColumns)
en Wisej.Web.DataGridView.RefreshColumns()
en Wisej.Web.DataGridView.RefreshColumnsAndRows()
en Wisej.Web.DataGridView.OnBindingContextChanged(EventArgs e)
en Wisej.Base.ControlBase.OnParentBindingContextChanged(EventArgs e)
en System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
en Wisej.Base.ControlBase.OnBindingContextChanged(EventArgs e)
en Wisej.Web.ContainerControl.get_BindingContext()
en Wisej.Base.ControlBase.get_BindingContext()
en Wisej.Web.DataGridViewInternal.DataGridViewDataConnection.SetDataConnection(Object dataSource, String dataMember)
en Wisej.Web.DataGridView.set_DataSource(Object value)
en IdemWisejDemo.TestForm.btnAccept_Click


Next connection string works ok, but you need create App_Data folder in project, and put local database there. This way no error throws, if it is useful for you.

static string ConnectionString => $”Data Source=\”|DataDirectory|\\{DatabaseFile}\”;Open Mode=NonExclusiveReadWrite;Password=\”{SensistiveEncriptionKey}\””;

  • You must to post comments
Best Answer

Hi Ser,

the problem in your code is HttpRuntime.BinDirectory which is null in Wisej.

You can find ways to determine the right PATH in this discussion:

Hope that helps.

Best regards

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json mixin.theme