Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 20:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Question] Weird Dictionary problem

Discussion on [Question] Weird Dictionary problem within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
[Question] Weird Dictionary problem

I have been struggling with this for some time now, so I decided to ask. How on earth can this :
PHP Code:

lock 
(Inventory)
{
                if (
Inventory.ContainsKey(UID))
                {
                        
Console.WriteLine("Removing key : " UID);
                        if (
Inventory[UID] != null)
                            
Inventory.Remove(UID);
                }

throw a System.Collections.Generic.KeyNotFoundException?
KraHen is offline  
Old 12/07/2011, 18:35   #2
 
Lateralus's Avatar
 
elite*gold: 0
Join Date: May 2005
Posts: 1,892
Received Thanks: 918
Quote:
Originally Posted by KraHen View Post
I have been struggling with this for some time now, so I decided to ask. How on earth can this :
PHP Code:

lock 
(Inventory)
{
                if (
Inventory.ContainsKey(UID))
                {
                        
Console.WriteLine("Removing key : " UID);
                        if (
Inventory[UID] != null)
                            
Inventory.Remove(UID);
                }

throw a System.Collections.Generic.KeyNotFoundException?
Try casting to an IDictionary and locking the SyncRoot object. See, this is why using a ConcurrentDictionary in a multithreaded project owns the hell out of the generic one. Also, the test determining if the value is null is useless in this implementation (correct me if I'm wrong).
Lateralus is offline  
Old 12/07/2011, 18:36   #3


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
You shouldnt be locking using the dictionary, you should be locking using a separate object.
Korvacs is offline  
Old 12/07/2011, 20:52   #4


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
None of these were the solutions, to be more precise these didn`t fix the error.

EDIT : Aaaand I also locked Inventory 2 times...
KraHen is offline  
Old 12/07/2011, 21:40   #5
 
Lateralus's Avatar
 
elite*gold: 0
Join Date: May 2005
Posts: 1,892
Received Thanks: 918
Quote:
Originally Posted by KraHen View Post
None of these were the solutions, to be more precise these didn`t fix the error.

EDIT : Aaaand I also locked Inventory 2 times...
Haha, well, you should still be locking an object instead of the dictionary.
Lateralus is offline  
Old 12/07/2011, 23:37   #6


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
Lol I just managed to actually fix this. Turns out when I was adding to the dictionary, I used a key generated with a method which didn`t match the item`s UID, which was the key when I tried to remove from the Dictionary, and it wasn`t even the Inventory dictionary which gave me the error LOL. All I had to do is empty my items table and change the last item uid in my text file to 0 instead of 1000.

MAJOR FAIL.

No, actually locking syncroot helped besides the upper error.
KraHen is offline  
Reply


Similar Threads Similar Threads
weird problem
08/05/2011 - CO2 Private Server - 0 Replies
well it was weird that when i finished coding an npc it comes up with so weird error..the error in case after #region but when i just refer the pointer to it it says..invalid expression and for the code it says it represent 32 bit smthing ANyways heres the pic showing that http://www5.0zz0.com/2011/08/05/04/743698916.jpg
[INFO][QUESTION] (Kinda) WEIRD THING
05/22/2011 - Grand Chase Philippines - 2 Replies
What is this file. Looks suspicious. http://imageshack.us/m/818/363/unledzl.png Feel free to discuss. MODS Close the thread if it gets spammy.
Weird Lag problem
12/26/2009 - Dekaron - 0 Replies
i have 2 2moons copies, one orginal another one with csv editen for ego spawn. I run orginal with ReXIGNation v1.54a to login my nub char. And again with ReXIGNation v1.54a i run my csv edited client, CRC bybass checked. , before logging in i turn on CE hacks. well, My pc is good enough intell quad q660 4gb ddr2 ram HD4870 Video
a weird problem
03/23/2009 - Silkroad Online - 4 Replies
ok i have a cyber cafe... master pc: vga card: ati radeon xpress 1250 processor: amd athlon 64 x2 dual core processor 4000+ ram: 2 gb cyber pc's: vga card: ati radeon hd3200 processor: amd athlon 64 x2 dual core processor 5000+
a weird problem
03/22/2009 - Silkroad Online - 0 Replies
ok i have a cyber cafe... master pc: vga card: ati radeon xpress 1250 processor: amd athlon 64 x2 dual core processor 4000+ ram: 2 gb cyber pc's: vga card: ati radeon hd3200 processor: amd athlon 64 x2 dual core processor 5000+



All times are GMT +1. The time now is 20:43.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.