Object reference not set to an instance

K

kejeiri

When I use my Dll in which I defined my dataset the following error
occurs:
Object reference not set to an instance or (in French "Une exception
non gérée du type 'System.NullReferenceException' s'est
produite dans system.data.dll, Informations supplémentaires : La
référence d'objet n'est pas définie
à une instance d'un objet") is due to the use of this instruction :

....
...........
Dim fkc As ForeignKeyConstraint

Here ---> fkc = New ForeignKeyConstraint("personnePhysique_telephones",new
DataColumn(){Me.tablepersonnePhysique.personnePhysique_IdColumn}, new
DataColumn(){Me.tabletelephones.personnePhysique_IdColumn})<--- Here


Me.tabletelephones.Constraints.Add(fkc)
fkc.AcceptRejectRule = System.Data.AcceptRejectRule.None
fkc.DeleteRule = System.Data.Rule.Cascade
fkc.UpdateRule = System.Data.Rule.Cascade
..
..........
......

I checked the definition of all objects and apparently are well
defined.
Please what's wrong? Above u've whole code of my application

Sincerely yours

MOMO
 
S

Sahil Malik

Kejeiri,

Pardonnez mon français. J'ai besoin pratique. Je répéterai en anglais aussi.
Je suspecte cela tablepersonnePhysique ne tient pas un object. :)

WHEW !! Hope I didn't totally murder the language - back to english.

I feel that you might not have called a new on the strongly typed ds
tablepersonnePhysique. Hopefully you have declared the strongly typed ds,
that is available as a class. Just like a regular dataset, you need to call
a "new" on it. Also, you mentioned that you checked the defintion - i.e.

If your strongly typed ds is tablepersonnePhysique, you need code like ---

tablepersonnePhysique m_tablepersonnePhysique = new tablepersonnePhysique()
;
... then use m_tablepersonnePhysique to do your work .. remember the
constraint will exist only in the instance, if you wish the constraint to
exist regardless - you need to put that in the xsd for the strongly typed
dataset.

Regards,

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
C

Cor Ligthert

Sahil,
Pardonnez mon français. J'ai besoin pratique. Je répéterai en anglais
aussi.
Je suspecte cela tablepersonnePhysique ne tient pas un object. :)

Ik zal volgende keer alles in het Nederlands aan je vragen, misschien kan
Miha het dan in het Sloveens doen, kan je nog wat meer oefenen.

Nastempnym razem spytam Cebie po holdendersku, moze Miha napisze po
slovensku, to moze bedziesz mógt troche pocwiczyc. Miha, to jest po polsku.

:)

Cor
 
M

mohamed larbi kejeiri

Thank u for ur answers... Well the problem are realy complecated...
indeed my object reference has an early created but the problem carry on
!!!...
Below u've the link to the complete code :

http://www.geocities.com/mkejeiri/completeCode.txt

Use ctr-f and look for pattern "here", the code when the error occurs,
is delimited as illustrated below:
'here
....
'end here

Many thanks
MOMO.
 
M

mohamed larbi kejeiri

Ur French is very good and ur dutch too!!! but my dutch is even worse
than chinese...
BR
MOMO
 
S

Sahil Malik

Cor,

Mijn Nederlands is werkelijk slecht :) Mijn Engels is nog slechter. If you
ask me questions in Dutch, tey mein terre sawalan da jawab punjabi wich
deyangaa (If you ask me questions in dutch, then I will reply your questions
in punjabi). CHAK DEY FATTE !! :p

Slovenian - now that's beyond me man !!! Whats the translation?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
PS: We're really going OT here, hope the Microsoftie's don't mind !!
 
S

Sahil Malik

Okay seeing the code made a difference.

It appears that you took a strongly typed dataset's cs code and customized
that - which is a good experiment I'd never bet my life upon.

But anyway - the problem is (and I had to remove all the
System.Debugger.Stepthrough's so I could actually get to the real problem
and it wasn't between 'here and 'end here).

So the real problem is ----

In the datatable telephonesDataTable 's "InitClass", you forgot to include a
definition for columnpersonnePhysique_Id, and when the following code runs

Friend ReadOnly Property personnePhysique_IdColumn() As DataColumn

Get

Return Me.columnpersonnePhysique_Id

End Get

End Property

,,,,,,,,,,,,, It bombs !!!

There you go .. Hope this would fix it, also when debugging this code,
remove the System.Debugger.StepThrough's or you'd never zero in on the real
problem.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
S

Sahil Malik

That was only one of the problems ... after that I am running into some sort
of problem with how Friend classes behave. Seeing the original XSD would
help a lot. (Or maybe a diagram of how you intend all your datatables and
relations to look).

Any reason you had to modify autogenerated code?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
M

mohamed larbi kejeiri

sahil,
So, in the InitClass() (inside Class telephonesDataTable), the code must
like that :
........

Private Sub InitClass()
Me.columntelephones_Id = New DataColumn("telephones_Id",
GetType(System.Int32), Nothing, System.Data.MappingType.Hidden)
Me.Columns.Add(Me.columntelephones_Id)
Me.columnacteur_Id = New DataColumn("acteur_Id",
GetType(System.Int32), Nothing, System.Data.MappingType.Hidden)
Me.Columns.Add(Me.columnacteur_Id)
Me.columnpersonnePhysique_Id = New
DataColumn("personnePhysique_Id", GetType(System.Int32), Nothing,
System.Data.MappingType.Hidden)
Me.Columns.Add(Me.columnpersonnePhysique_Id)
Me.Constraints.Add(New UniqueConstraint("Constraint1", New
DataColumn() {Me.columntelephones_Id}, True))
Me.columntelephones_Id.AutoIncrement = True
Me.columntelephones_Id.AllowDBNull = False
Me.columntelephones_Id.Unique = True
End Sub
.....

As for the xsd schema u can download it from :
http://www.geocities.com/mkejeiri/MOMO.zip
The msgEvenementsServeurActes.xsd is the root file...
The schema is not normalized according the relational model…
First, I decided to cut it in different level and generate a partial
dataset using xsd.exe utility and then integrate the whole dataset
mapping the schema :)...
Many thanks.
 
M

mohamed larbi kejeiri

Malik,
Well I'm not using CS language but the VB.net... can you briefly explain
to me how u preceded to detect the error "missing statement in
initClass()..."
Well, I don't find System.Debugger.StepThrough... Do u mean
System.Diagnostics.DebuggerStepThrough()? ...must be ignored?
Best Regards.
MOMO.
 
S

Sahil Malik

Momo,

Yes I mean System.Diagnostincs.DebuggerStepThrough()

Essentially putting that on top of a portion of your code means - Vstudio is
not going to debug thru there.

By removing those, you'd be able to debug thru your class normally, and know
the *real* place where the error is happening.

I had to fix InitClass at a few places, but then I mentioned that I am
running into a few problems with friend classes which is why I need to see
the xsd. Anyway, when you remove the System.Diag.DST's , you'll know where
the error is happening.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top