Error details: Value cannot be null. Parameter name: key
-
30 Nisan 2012 Pazartesi 07:27
When I try to export data into excel in editable grid screen I get this error
An error occurred while running the screen. You can close the screen or ignore the error and continue using the screen. Error details: Value cannot be null. Parameter name: key
What does it mean ?
- Taşıyan Justin AndersonMicrosoft Employee, Moderator 01 Mayıs 2012 Salı 00:06 (From:Visual Studio LightSwitch - General Questions)
- Taşıyan Steve HoagMicrosoft Employee, Moderator 15 Ağustos 2012 Çarşamba 04:38 forum retired (From:LightSwitch in Visual Studio 2012 RC)
Tüm Yanıtlar
-
30 Nisan 2012 Pazartesi 08:05
That would be a NullReferenceException.
Run your project in debug up to the point when you are about to get this error then go to the VS IDE and click Debug | Exceptions, tick the box next to Common Language Runtime Exceptions and click OK. Now click the Export to Excel button in your application and, with a little luck, you should drop into the code editor at the point the error occurs. If you hover the mousepointer on all the variables in the line that has errored you might be able to fine out which one is Null (Nothing in VB).
Don't forget to go back to the Exceptions dialog and click Reset All to turn exception handing back to normal.
Simon Jones
If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly. -
30 Nisan 2012 Pazartesi 08:13Moderatör
That would be a NullReferenceException.
It's actually an ArgumentNullException.Justin Anderson, LightSwitch Development Team
-
30 Nisan 2012 Pazartesi 08:14Pardon me for not being quite awake.
Simon Jones
If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly. -
30 Nisan 2012 Pazartesi 08:58
Thanks for the tip but, as you mentioned it didn't drop into code editor. You think this could be the culprit ?
partial void q59_HowSTI_other_Validate(EntityValidationResultsBuilder results) { if (this.q59_HowSTI_other != null && !System.Text.RegularExpressions.Regex.IsMatch(this.q59_HowSTI_other, @"^[a-zA-Z]+$")) { results.AddPropertyError("Only alphabets allowed."); } }
I commented the above code and tried again still same problem.
- Düzenleyen JaysonChow 30 Nisan 2012 Pazartesi 08:59
-
30 Nisan 2012 Pazartesi 13:34
No, I don't think it can be that code that is causing the exception.
1) You have coded to cope with this.q59_HowSTI_other being null
2) You have tried commenting out the code and the error still occurs.
Simon Jones
If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly. -
01 Mayıs 2012 Salı 00:05
How to identify the problem then ? I found these could be the problems too
1)
. LS table with a many to zero or 1 relationship with a view off a database where the summary field for the view is a required field (such as name or ID) throws an error if left empty.
Exception: Value cannot be null. Parameter name: body
2)
The key here is "Value cannot be null". Parameter name is misleading. This is telling you that an entity was retrieved and it has a required field containing a null value
Error launching the screen. Error : Value cannot be null. Parameter name: screen
I used to have table with many to zero or one but I did update my data model. I'm using vs2011 beta.
- Düzenleyen Yann DuranModerator 24 Ocak 2013 Perşembe 02:44 Fixed link text
-
01 Mayıs 2012 Salı 07:33
We do not have enough information in order to diagnose the problem which is why I suggested turning on all exception trapping. That usually leads you to the problem.
Simon Jones
If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly. -
02 Mayıs 2012 Çarşamba 21:01
I've got the same problem when upgrading to LS2Beta. It seems that when using a 'Data Item' which is empty it creates this problem.
To reproduce add a Data Item of type Query return type Single or Default of a random table. Run the application and open screen. (or try the link in my thread below).
See my thread
rdk
- Düzenleyen Yann DuranModerator 24 Ocak 2013 Perşembe 02:44 Fixed link text
-
10 Ağustos 2012 Cuma 20:41
I encountered the same issue as Jason describes in the first message above.
I found the following information in the debug messages:
{System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.LightSwitch.Details.Framework.Internal.StringValueConversion.SupportedValueStringValueStringValueConverter.Microsoft.LightSwitch.Details.Framework.Internal.StringValueConversion.IStringValueConverter.ConvertToString(Object value, CultureInfo culture)
at Microsoft.LightSwitch.Details.Framework.Internal.StringValueConversion.DefaultDataFormatter.Microsoft.LightSwitch.Runtime.DataFormatter.IDataFormatter.FormatData(Object value)
at Microsoft.LightSwitch.Runtime.Services.Implementation.EntityExportService.DataTable.FormatColumn(Int32 index, IDataOutputPort device)
at Microsoft.LightSwitch.Runtime.Services.Implementation.ExcelDataOutputPort.ExcelDataOutputSession.FormatData(IDataTable dataTable)
at Microsoft.LightSwitch.Runtime.Services.Implementation.ExcelDataOutputPort.ExcelDataOutputSession.SendData(Object data)
at Microsoft.LightSwitch.Presentation.Implementation.Controls.ExportCollectionDataCommand.<>c__DisplayClass8.<Execute>b__2()}
Any ideas?
Thanks for your help!
Thanks, Edgar Walther
-
22 Ocak 2013 Salı 17:25
I had a the same problem with exporting a VisualCollection which had a field with a choice list.
If the field is not required, it might be empty. Trying to find the choice for the key gives the problem.
Filling in the missing values and putting the field as required resolved the problem.
Ciao,
Bert
- Yanıt Olarak Öneren Yann DuranModerator 24 Ocak 2013 Perşembe 02:45