NullReferenceException on app.Init()

Jul 15, 2015 at 5:54 PM
Edited Jul 15, 2015 at 5:55 PM
I implemented a small Console app based on the quick start guide and (after updating the code based on the changes in the Change History and looking into the sample which is a class library) no matter how I try I always get NullReferenceException in app.Init(), with the following stack trace:
at Vita.Entities.ManyToManyAttribute.Apply(AttributeContext context, Attribute attribute, EntityMemberInfo member)
at Vita.Entities.Model.Construction.EntityModelBuilder.FindAndApplyAttribute[TAttr](EntityMemberInfo member)
at Vita.Entities.Model.Construction.EntityModelBuilder.ProcessSpecialAttributes()
at Vita.Entities.Model.Construction.EntityModelBuilder.BuildModel()
at Vita.Entities.EntityApp.Init()
at Minibizz.Selenium.TestsConfig.Configure(String connectionString) in c:\Users\drni381\Documents\Visual Studio 2013\Projects\Minibizz.Selenium\TestsConfig.cs:line 21
at Minibizz.Selenium.Program.Main(String[] args) in c:\Users\drni381\Documents\Visual Studio 2013\Projects\Minibizz.Selenium\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Jul 15, 2015 at 6:09 PM
Hard to say, can you pls post definition of your entity(ies) with ManyToMany attribute?
also, can you try to run it with inclusion of source VITA project, so you can locate the place?
Jul 15, 2015 at 8:40 PM
Edited Jul 15, 2015 at 8:41 PM
From what I see in sources, most likely you have invalid setup of link entity; the code fails to find a property in link entity that references back the 'this' entity that holds the many-to-many list. Look at IBook.Authors property and IBookAuthor link entity. I will add explicit check in this place to throw a clear error indicating the problem.
Jul 15, 2015 at 10:18 PM

Makes sense. I will look into it tomorrow. I have only two entities with ManyToMany relation (and their link table) I will first try without these three. Then I will do as you said.

KR,
Reza.




On Wed, Jul 15, 2015 at 12:41 PM -0700, "rivantsov" <[email removed]> wrote:

From: rivantsov

From what I see in sources, most likely you have invalid setup of link entity; the code fails to find a property in link entity that references back the 'this' entity that holds the many-to-many list. Look at IBook.Authors property and IBookAuthor entity. I will add explicit check in this place the throw clear error indicating the fault.
Jul 16, 2015 at 10:54 AM
Here is current status ;)
I removed all the entities but one and I switched from SQL CE to SQL (anyway SQLCE is discontinued) and this time in the same method (App.Init() ) I had another error. Then I pointed to a freshly build Vita.dll and it's source code, while debugging in its source code I found out that the dll is politely providing the reasons in a list and it's basically telling me that I have used [Auto] for an int column! I changed it to [Auto(AutoType.Indentity)] and now it works. Next step would be to add again all the entities.
Marked as answer by irezax on 7/16/2015 at 8:06 AM