Share via


Unhandled Exeption: Value cannot be null. Parameter name: collection

Question

Friday, October 17, 2008 8:38 PM

I got a unhandled exception from Office Word 2003 when I run my c# program on .net and tried to plug-in the button into the word toolbar.

It is said:

"Value cannot be null.

Parameter name: collection

************** Exception Text **************

System.ArgumentNullException: Value cannot be null.

Parameter name: collection

   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)

   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)

   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)

   at RQChecker.ThisAddIn.loadDictionaries() in C:\zzf\backup\RQCheckernew\RQChecker\RQChecker\ThisAddIn.cs:line 114

   at RQChecker.ThisAddIn.ThisAddIn_Startup(Object sender, EventArgs e) in C:\zzf\backup\RQCheckernew\RQChecker\RQChecker\ThisAddIn.cs:line 75

   at Microsoft.Office.Tools.AddIn.OnStartup()

   at RQChecker.ThisAddIn.FinishInitialization() in C:\zzf\backup\RQCheckernew\RQChecker\RQChecker\ThisAddIn.Designer.cs:line 70

   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName)

   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteCustomizationStartupCode()

   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteEntryPointsHelper()

   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.Microsoft.VisualStudio.Tools.Applications.Runtime.IExecuteCustomization2.ExecuteEntryPoints()

************** Loaded Assemblies **************

Anyone has the idea, what is it mean? My program runed very well before, the button that my code does could be pluged in, but just suddenly this error, really desperate :(

All replies (2)

Friday, October 17, 2008 8:51 PM âś…Answered

In your ThisAddIn class, on line 114 (in your loadDictionaries()) method, you're calling List<T>.AddRange, and passing in a variable that's set to null.

Post your loadDictionary method, and we can help try to track down what the issue may be.


David Morton - http://blog.davemorton.net/


Friday, October 17, 2008 9:13 PM

 Thanks David, I fixed it now. Really appreciate!!!! :)