[HELP]Invalid Operation Exception.

12/02/2008 19:30 Incariuz#1
Well... Over the past little while, I have fixed quite a few issues regarding stability on the source I'm playing with, but have now found another that has left me stumped.

InvalidOperationException

It's taking effect under the section

Code:
public static void MobAttacksChar(SingleMob Mob, Character Attacked, byte AtkType, uint Dmg)
for the line

Code:
foreach (DictionaryEntry DE [COLOR="Red"]in[/COLOR] AllChars)
And it highlights the red writting, just "in" that's it.

I've spent a bit of time reading around about it, but really can't make sense of why it's even happening for me, so I can't even begin to try and figure out how to fix it.

If anyone has any idea's, a bit of input on the subject would be appreciated.
12/02/2008 22:18 InfamousNoone#2
Long story short, the hashtable was edited (something added/removed) while you were looping through it.
12/02/2008 22:23 sherwin9#3
Just ignore it, it's not threathning your server isn't it?
12/02/2008 22:54 Korvacs#4
Quote:
Originally Posted by sherwin9 View Post
Just ignore it, it's not threathning your server isn't it?
....lol? it might only get 10 entrys into the hashtable in which case it means that the check is only performed on some of the clients and not others, how can you say thats not threatening a server?
12/02/2008 23:00 Incariuz#5
Well infamous, I read something about possible issues a nullreferenceexception could cause in regards to that, or something along those lines, please ignore if I made no sense with that. only thing I can determine under such a circumstance would be this line.

Code:
if (Attacked != null && Charr != null)
I added that in due to an old crash issue I was having in that exact same section. I have actually editted a few other sectins with similar too. My server stability has went up durastically since then, but now this issue has arisen. Could that possibly be the cause of it?

@sherwin.

Yes, it can be an issue. Sure it doesn't occur with less then 25 people on my server, or more then once within a 24 hour period, but it's still a stability issue. And with my learning on building a private server, I would like to know what types of things cause issues, and how to avoid or correct them. Right now I'm using a source I did not build, for the sole reason I would fail miserably from scratch, therefor I need some hands on practise.
12/02/2008 23:02 InfamousNoone#6
Quote:
Originally Posted by sherwin9 View Post
Just ignore it, it's not threathning your server isn't it?
Any error threatens your server (:

Quote:
Originally Posted by Incariuz View Post
Well infamous, I read something about possible issues a nullreferenceexception could cause in regards to that, or something along those lines, please ignore if I made no sense with that. only thing I can determine under such a circumstance would be this line.

Code:
if (Attacked != null && Charr != null)
I added that in due to an old crash issue I was having in that exact same section. I have actually editted a few other sectins with similar too. My server stability has went up durastically since then, but now this issue has arisen. Could that possibly be the cause of it?

@sherwin.

Yes, it can be an issue. Sure it doesn't occur with less then 25 people on my server, or more then once within a 24 hour period, but it's still a stability issue. And with my learning on building a private server, I would like to know what types of things cause issues, and how to avoid or correct them. Right now I'm using a source I did not build, for the sole reason I would fail miserably from scratch, therefor I need some hands on practise.
Nah, one thread was mostlikely adding or removing a client, and another one trying to loop between it, google and learn about thread synchronization, it was one of the first things I looked into implementing when I started ACO.
12/02/2008 23:07 Incariuz#7
Ok, I'll do a bit of research on that then. I may still pop back to ask a few questions depending, but I'll try only to do so as a last resort. Thanks for the info.
12/03/2008 08:45 alexbigfoot#8
does "lock statements" work in this case?
12/03/2008 13:47 InfamousNoone#9
Quote:
Originally Posted by alexbigfoot View Post
does "lock statements" work in this case?
Only if you used properly. Though lock could be a performance killer on a multi-threaded server.
12/03/2008 15:22 Incariuz#10
That's what I was thinking while reading about it. Sure, it would stop interuption, but on the same note, it could slow down the amount of information being transferred which could cause issues, depending on the information.
12/03/2008 15:58 alexbigfoot#11
then how could this problem be stopped? because this problem is killing my server :|
12/03/2008 17:43 Incariuz#12
To be honest, I don't know. Everything I'm searching about the multi thread synchronization is leading me to using the lock method.

I'm going to go over this more later...

[Only registered and activated users can see links. Click Here To Register...]

make sure I understand it fully before attempting to make changes. If it ends up working out good for me, I'll let you know. Prob won't try till 2morow evening though, have some running around to do, so can't put enough time into reading and testing right now.
12/03/2008 17:59 Korvacs#13
Why do you have more than 1 thread accessing the hash at anyone time anyways?
12/03/2008 18:48 alexbigfoot#14
Quote:
Originally Posted by Korvacs View Post
Why do you have more than 1 thread accessing the hash at anyone time anyways?
lol?, u want to say, if only 1 thread is accessing the hashtable, it will never give the error?
12/03/2008 21:41 InfamousNoone#15
Quote:
Originally Posted by alexbigfoot View Post
lol?, u want to say, if only 1 thread is accessing the hashtable, it will never give the error?
Yes, but... well; I'll let you figure out my but on your own.