(0xc0000005) 'Access violation': LINQ to SQL WPF VB.NET -
application compiles no errors. application runs ends no debug errors. stepping through it, cuts designer @ line output showing:
"the program '[24680] appname.vshost.exe' has exited code -1073741819 (0xc0000005) 'access violation'."
crashes on line:
dim c_instancedetail t_instance_detail = (from instdet in db.t_instance_details instdet.id = guinstance_id select instdet).single
in sub:
private sub refresh_pca_instancedetail() dim c_instancedetail t_instance_detail = (from instdet in db.t_instance_details instdet.id = guinstance_id select instdet).single me.datacontext = c_instancedetail me.instancedetailtypeview = ctype(collectionviewsource.getdefaultview(me.datacontext), bindinglistcollectionview) end sub
edit: class variables:
private db new appdatabase_dbdatacontext 'appdatabase_db being name of dbml file - appdatabase_db.dbml private instancedetailtypeview bindinglistcollectionview property guinstance_id guid
t_instance_detail created linq sql classes , i've tried removing , re-adding - no change
this works (and returns 1 record):
dim c_instancedetail = (from instdet in db.t_instance_details instdet.id = guinstance_id select instdet)
i'm new linq sql , wpf, i'm assuming i'm doing wrong or using linq sql classes in why unintended. if can let me know i'm doing wrong here, , how should doing this, great thanks.
i think issue possibility of not returning record (even though returning 1 record @ point in time). below fixed it:
private sub refresh_pca_instance() dim c_instance ienumerable(of t_instance) c_instance = (from inst in db.t_instances inst.id = guinstance_id select inst) if c_instance.count = 1 me.datacontext = c_instance me.instancedetailtypeview = ctype(collectionviewsource.getdefaultview(me.datacontext), bindinglistcollectionview) elseif c_instance.count > 1 me.datacontext = c_instance.first me.instancedetailtypeview = ctype(collectionviewsource.getdefaultview(me.datacontext), bindinglistcollectionview) end if end sub
edit: more this, find better/other ways:
private sub refresh_pca_instance() dim c_instance ienumerable(of t_instance) c_instance = (from inst in db.t_instances inst.id = guinstance_id select inst).first me.datacontext = c_instance me.instancedetailtypeview = ctype(collectionviewsource.getdefaultview(me.datacontext), bindinglistcollectionview) end sub
or
private sub refresh_pca_instance() dim c_instance ienumerable(of t_instance) c_instance = (from inst in db.t_instances inst.id = guinstance_id select inst) me.datacontext = c_instance.first me.instancedetailtypeview = ctype(collectionviewsource.getdefaultview(me.datacontext), bindinglistcollectionview) end sub
Comments
Post a Comment