Ovo je kod:
Code (csharp):
XDocument xmlSource = XDocument.Load("myXmlDoc.xml");
var Clanovi = from nesto in xmlSource.Descendants("clanovi")
where nesto.Element("ime").Value.Contains(textBox1.Text) //OVDJE PUCA
select new
{
ID = nesto.Element("id"),
IME = nesto.Element("ime"),
PREZIME = nesto.Element("prezime")
};
foreach (var proradivise in Clanovi)
{
imecmb.Text = proradivise.IME.Value;
prezimecmb.Text = proradivise.PREZIME.Value;
textBox2.Text = proradivise.ID.Value.ToString(); //koristiti za XAML
XDocument xmlSource = XDocument.Load("myXmlDoc.xml");
var Clanovi = from nesto in xmlSource.Descendants("clanovi")
where nesto.Element("ime").Value.Contains(textBox1.Text) //OVDJE PUCA
select new
{
ID = nesto.Element("id"),
IME = nesto.Element("ime"),
PREZIME = nesto.Element("prezime")
};
foreach (var proradivise in Clanovi)
{
imecmb.Text = proradivise.IME.Value;
prezimecmb.Text = proradivise.PREZIME.Value;
textBox2.Text = proradivise.ID.Value.ToString(); //koristiti za XAML
Ono sto mi ne ide nikako u glavu, je da sam na verziji 2.2. a a od verzije 1.4 koristim LINQ (gore navedeni code). Znaci sve se vrtilo odlicno, jer zaboga ne bih dogurao do novije 2.2. I odjednom poce problem.
Kad ubacim try/catch:
Code (csharp):
try
{
int alfa = 0;
XDocument xmlSource = XDocument.Load("myXmlDoc.xml");
var Clanovi = from nesto in xmlSource.Descendants("clanovi")
where nesto.Element("ime").Value.Contains(textBox1.Text)
select new
{
ID = nesto.Element("id"),
IME = nesto.Element("ime"),
PREZIME = nesto.Element("prezime")
};
foreach (var proradivise in Clanovi)
{
imecmb.Text = proradivise.IME.Value;
prezimecmb.Text = proradivise.PREZIME.Value;
}
}
catch (NullReferenceException er)
{
//MessageBox.Show("neka greska");
}
try
{
int alfa = 0;
XDocument xmlSource = XDocument.Load("myXmlDoc.xml");
var Clanovi = from nesto in xmlSource.Descendants("clanovi")
where nesto.Element("ime").Value.Contains(textBox1.Text)
select new
{
ID = nesto.Element("id"),
IME = nesto.Element("ime"),
PREZIME = nesto.Element("prezime")
};
foreach (var proradivise in Clanovi)
{
imecmb.Text = proradivise.IME.Value;
prezimecmb.Text = proradivise.PREZIME.Value;
}
}
catch (NullReferenceException er)
{
//MessageBox.Show("neka greska");
}
Radi bez problema. Sto je najcudnije sad nijedna stara verzija nece da radi. Ista greska se javlja?!?!?
Da sam nesto dodavao... jesam. Ali kako da ni stare verzije ne rade sada?
[IMG]http://img233.imageshack.us/img233/5078/thumbnailte1.th.jpg[/IMG]
They say I look like daddy :D