0

I Used a delegate action as a parameter in a method as follows:

private IEnumerable<SC.ServerPathServices.GAFPFileInfo> StartProjectArchive(Int32 projectID, Int32 sourceServerPathID, Action uiRefresh,Action<IEnumerable<ProjectFile>> PopUpFiles)

Here I have two delegates. I have a problem with PopUpFiles Delegate.

I am calling this in my method by passing list of files as a parameter to PopUpFiles As follows:

 if(PopUpFiles!=null)
                   PopUpFiles(filesModifiedInSourceServer);

Here filesModifiedInSourceServer contains list of files. I am calling this in a code behind file as follows:

archiveResponse = projectManager.StartProjectArchive(projectId, 0, () =>
                     {
                         foreach (Control control in tdFileList.Controls.Cast<Control>())
                         {
                             if (control is Dell.AFP.UserControl.ProjectFileListBaseControl)
                             {
                                 ((ProjectFileListBaseControl)control).Refresh();
                             }
                         }
                     },
                     (filesModifiedInSourceServer)=>
                         {
                             if (filesModifiedInSourceServer != null && filesModifiedInSourceServer.Count > 0)
                             {
                             PopUpModifiedFiles(filesModifiedInSourceServer);
                             }
                         });

But in the above code when I am passing parameter for the delegate action PopUpFiles I used filesModifiedInSourceServer as a parameter. It is giving me an error as delegate action does not take one argument. How else I can pass the parameter? this is resolved. Now I am getting object reference error while calling that method. I do not know why it is throwing object reference error.

kartikasi
  • 29
  • 2
  • 9
  • What line is the error? – leppie Dec 02 '14 at 05:25
  • while passing parameters to that action. Here is the code (filesModifiedInSourceServer)=> here only I am getting that error – kartikasi Dec 02 '14 at 05:27
  • I dont see anything obviously wrong with the syntax (but then again, I am still only on my first cup of coffee ;p). Edit: What is the signature of `PopUpModifiedFiles`? Also `filesModifiedInSourceServer.Count` is not right, should be `.Count()` given that it is `IEnumerable` – leppie Dec 02 '14 at 05:29
  • 1
    That error? What's the error message? – MarcinJuraszek Dec 02 '14 at 05:36
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Patrick Hofman Dec 02 '14 at 07:47

0 Answers0