alexander-pick / MKMTool

MKMTool ist a helper application I wrote for tinkering around with optimization of sale processes on magiccardmarket.eu and the idea of automisation of some tasks most people wouldn’t be able to get done by pure manpower.
GNU Affero General Public License v3.0
65 stars 15 forks source link

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. #45

Closed goosedeersolutions closed 3 years ago

goosedeersolutions commented 3 years ago

When I run the Update Prices options, it gets through 3 cards and then throws an unhandled exception.

Error Log:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MKMTool.MKMBot.traverseSimilarItems(XmlNodeList similarItems, MKMMetaCard article, Boolean ignoreSellersCountry, Int32& lastMatch, List`1 prices) in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MKMBot.cs:line 1052
   at MKMTool.MKMBot.appraiseArticle(MKMMetaCard article, Dictionary`2 myStock) in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MKMBot.cs:line 883
   at MKMTool.MKMBot.UpdatePrices() in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MKMBot.cs:line 669
   at MKMTool.MainView.updatePriceRun() in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MainView.cs:line 262
   at MKMTool.MainView.<updatePriceButton_Click>b__27_0() in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MainView.cs:line 272
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at MKMTool.MainView.<updatePriceButton_Click>d__27.MoveNext() in C:\Users\RW\Downloads\MKMTool-master\MKMTool\MainView.cs:line 272
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
tomasjanak commented 3 years ago

The latest update (0.8.0.2) should fix the crashes. However, the problem seems to be with country code of a seller not being recognized, which is odd. If you are running with "filter by countries", you should now get an error message which says which country code is the one not recognized. If you do, let me know so that I can add it to the list.

goosedeersolutions commented 3 years ago

Hello,

The error that is output to the log is Error with filtering sellers by countries: country code HK not recognized. Seller will be ignored.. I am only filtering by two countries in the settings; United Kingdom, and Germany.

tomasjanak commented 3 years ago

Interesting. HK is the code for Hong Kong. Which does not seem to be supported by cardmarket, in "user search" you cannot even choose Hong Kong and if I try to create a new account, I cannot choose Hong Kong as my country...so I have no idea how is there a seller from Hong Kong. I suppose I can add it to the list of supported countries, but then it will also appear in the "filter by country" menu...

I will leave it as is for now, so you will be getting this error (it does not appear very often, right?), but your card is still priced fine, it just ignores the price of that one seller.

goosedeersolutions commented 3 years ago

I believe it is still pricing the card correctly, but I cannot be 100% sure on that.

Sleepy-N commented 3 years ago

I get this error when trying to view my inventory... New here sorry if, this is a dumb question.

tomasjanak commented 3 years ago

I get this error when trying to view my inventory... New here sorry if, this is a dumb question.

The "System.Collections.Generic.KeyNotFoundException"? Are you on version 0.8.0.3? If so, post the whole text of the error please.

Sleepy-N commented 3 years ago

It is in dutch so..., i've probably done something wrong. 18/01/2021 8:41:17, version: 0.8.0.3 Error with listing stock in Stock View: De gegeven sleutel is niet aanwezig in het woordenboek.

tomasjanak commented 3 years ago

It is in dutch so..., i've probably done something wrong. 18/01/2021 8:41:17, version: 0.8.0.3 Error with listing stock in Stock View: De gegeven sleutel is niet aanwezig in het woordenboek.

It's normal to have the error message in your language and it's easy to translate it online, so that's not an issue. But I don't see what could be wrong. In your config.xml, do you have UseStockGetFile set to false? If so, check your error_log.txt (should be next to your exe file) if there is some previous error that looks like this:

Error with writing Rarity [some rarity] for product id [some number]. Specified product ID does not exist.

Are you working with M:tG or some other game?

Sleepy-N commented 3 years ago

Got it! UseStockGetFile was set to false, I changed it to true and that did the trick. Sorry to bother you! Great job by the way :D

tomasjanak commented 3 years ago

Well...it should work correctly even with UseStockGetFile set to false. Is the "Error with writing Rarity..." somewhere in your error_log.txt? That's I think the only thing that could cause the "dictionary" error.

tomasjanak commented 3 years ago

I randomly stumbled upon a seller from Hong Kong, there really is (at least) one: https://www.cardmarket.com/en/Magic/Users/mtgmintcard So I've added Hong Kong among the supported countries in 0.8.1.0 (commit https://github.com/alexander-pick/MKMTool/commit/75bc1628bdaebeed73cba314623cad873be32cf6).