SourceForge has been redesigned. Learn more.
Close

InvalidCastException error

Help
cvsclient
2005-01-14
2013-04-25
  • cvsclient

    cvsclient - 2005-01-14

    hi,

    sorry for my simple question.

    i am developing a cvs client against the latest release of sharpcvslib library.

    while invoking the ImportModuleCommand, i encountered the InvalidCastException. in my case, i wanna import the D:\Tech\CVSCLIENT\temptest_import.txt into the repository as the "temp" module. here is my code:
    --------------------------------------
    CVSServerConnection temptheCVSConnection = new CVSServerConnection();
                ICSharpCode.SharpCvsLib.Misc.CvsRoot tempcvsRoot = 
                    new ICSharpCode.SharpCvsLib.Misc.CvsRoot(":pserver:garygu@localhost:2401:/Tech/CVS");
                WorkingDirectory tempworkingDir = new WorkingDirectory(tempcvsRoot,"D:\\Tech\\CVSCLIENT","temp");
                Entry ent = Entry.CreateEntry(@"D:\Tech\CVSCLIENT\temptest_import.txt");
                Folder fld = new Folder();   
                fld.Entries.Add(@"D:\Tech\CVSCLIENT\temptest_import.txt", ent);
                tempworkingDir.Folders.Add(@"D:\Tech\CVSCLIENT", fld);
                temptheCVSConnection.Connect(tempworkingDir,"gary750210");
                ICommand importNewProjCommand = new ImportModuleCommand(tempworkingDir,"importing test");

                importNewProjCommand.Execute(temptheCVSConnection);
                temptheCVSConnection.Close();
                MessageBox.Show("Done");
    ---------------------------

    the InvalidCastException error occurs at the line of
    foreach (Entry entry  in ((Folder)folder.Value).Entries) {
    inside the ImportModuleCommand.Execute method.

    is my code wrong? any suggestion will be greatly appreciated.

    Gary,

     
    • Clayton Harbour

      Clayton Harbour - 2005-01-14

      Hi Gary, that looks like a bug in the library, I took a look at cvs and it has been fixed. 

      There have been a number of fixes in the library/ console since that release.  If there is interest I could put together a developers release that would have a lot of these in place but would not be labeled "official release" quality. 

      Let me know if you think that would be helpful.

      Cheers,

      Clayton

       
      • cvsclient

        cvsclient - 2005-01-14

        thanks, Clayton,

        in this case that i am developing the client against the latest office release, which implemention of the ImportModuleCommand should i refer to? i mean the implementation with the bug above fixed.

        thanks,

        Gary

         
        • Clayton Harbour

          Clayton Harbour - 2005-01-14

          Hi Gary, I am not sure I understand the question.  The bug was fixed here: http://tinyurl.com/4eadw.  There has not been a release since that point, but I am willing to put out a development release stream if this will help you out.

           
          • cvsclient

            cvsclient - 2005-01-14

            hi Clayton,

            recently i have interruptted for a couple of times. i really appreciate for your great patience.

            after checking your post, i update the implementation of the ImportModuleCommand on my machine with the code from the link you provided. the InvalidCastException error went away. however, the import command still failed at the line of

            connection.SubmitRequest(new ImportRequest());

            the request above returns "error".

            then i went to the cvsroot, and found the temp folder was created, however, there was no file under it.

            can you do me more favors on this case? sorry for my frequent qustions to you.

            Gary,

             
            • Clayton Harbour

              Clayton Harbour - 2005-01-14

              Hi Gary, I am not sure if I know the reason for this one off the top of my head.  When you look at the messages being sent between the client and server what do you see?

               
              • cvsclient

                cvsclient - 2005-01-14

                Hi Clayton,

                by deeply investigating into the source, now i can execute ImportModuleCommand successfully,although the connection.SubmitRequest(new ImportRequest()); still returns "error". anyway, the import is ok:)

                however, when i wanna checkout the module just imported above, it failed at the "expand-modules" request with the "error" returned. here is the my code to do the CheckoutCommand:

                ------------------------
                CVSServerConnection temptheCVSConnection = new CVSServerConnection(); 
                ICSharpCode.SharpCvsLib.Misc.CvsRoot tempcvsRoot = 
                new ICSharpCode.SharpCvsLib.Misc.CvsRoot(":pserver:garygu@localhost:2401:/Tech/CVS";); 
                WorkingDirectory tempworkingDir = new WorkingDirectory(tempcvsRoot,"D:\\Tech\\CVSLOCAL\\","temp"); 

                temptheCVSConnection.Connect(tempworkingDir,"gary750210"); 
                ICommand chkcommand = new CheckoutModuleCommand (tempworkingDir);
                chkcommand.Execute(temptheCVSConnection); 
                temptheCVSConnection.Close(); 
                MessageBox.Show("Done"); 
                -------------------------------

                again, i am using the latest office release of the library. here is the code of the CheckoutCommand.Execute method on my machine:
                -------------------------------
                /// <summary>
                /// Execute checkout module command.
                /// </summary>
                /// <param name="connection">Server connection</param>
                public void Execute(ICommandConnection connection) {
                workingDirectory.Clear();

                connection.SubmitRequest(new CaseRequest());
                connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

                connection.SubmitRequest(new DirectoryRequest(".",
                workingDirectory.CvsRoot.CvsRepository +
                "/" + workingDirectory.ModuleName));

                connection.SubmitRequest(new ExpandModulesRequest());

                connection.SubmitRequest(
                new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME));

                if (workingDirectory.HasRevision) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION));
                connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision));
                }
                if (workingDirectory.HasDate) {
                connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE));
                connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString()));
                }
                if (workingDirectory.HasOverrideDirectory) {
                connection.SubmitRequest (
                new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                connection.SubmitRequest (
                new ArgumentRequest (workingDirectory.OverrideDirectory));
                }

                connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

                connection.SubmitRequest(new DirectoryRequest(".",
                workingDirectory.CvsRoot.CvsRepository +
                "/" + workingDirectory.ModuleName));

                connection.SubmitRequest(new CheckoutRequest());
                Manager manager = new Manager (connection.Repository.WorkingPath);
                if (LOGGER.IsDebugEnabled) {
                LOGGER.Debug ("looking for directories to add to the " +
                "entries file in=[" +
                this.workingDirectory.WorkingPath + "]");
                }
                }
                -------------------------------

                Clayton, can you help to check it? thanks, thanks, and thanks.

                Gary,

                 
    • cvsclient

      cvsclient - 2005-01-14

      Hi Clayton,

      by deeply investigating into the source, now i can execute ImportModuleCommand successfully,although the connection.SubmitRequest(new ImportRequest()); still returns "error". anyway, the import is ok:)

      however, when i wanna checkout the module just imported above, it failed at the "expand-modules" request with the "error" returned. here is the my code to do the CheckoutCommand:

      ------------------------
      CVSServerConnection temptheCVSConnection = new CVSServerConnection();
                  ICSharpCode.SharpCvsLib.Misc.CvsRoot tempcvsRoot = 
                      new ICSharpCode.SharpCvsLib.Misc.CvsRoot(":pserver:garygu@localhost:2401:/Tech/CVS");
                  WorkingDirectory tempworkingDir = new WorkingDirectory(tempcvsRoot,"D:\\Tech\\CVSLOCAL\\&quot;,"temp");

                  temptheCVSConnection.Connect(tempworkingDir,"gary750210");
                  ICommand chkcommand = new CheckoutModuleCommand (tempworkingDir);
                  chkcommand.Execute(temptheCVSConnection);
                  temptheCVSConnection.Close();
                  MessageBox.Show("Done");
      -------------------------------

      again, i am using the latest office release of the library. here is the code of the CheckoutCommand.Execute method on my machine:
      -------------------------------
      /// <summary>
              /// Execute checkout module command.
              /// </summary>
              /// <param name="connection">Server connection</param>
              public void Execute(ICommandConnection connection) {
                  workingDirectory.Clear();

                  connection.SubmitRequest(new CaseRequest());
                  connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

                  connection.SubmitRequest(new DirectoryRequest(".",
                                          workingDirectory.CvsRoot.CvsRepository +
                                          "/" + workingDirectory.ModuleName));

                  connection.SubmitRequest(new ExpandModulesRequest());

                  connection.SubmitRequest(
                      new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME));

                  if (workingDirectory.HasRevision) {
                      connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION));
                      connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision));
                  }
                  if (workingDirectory.HasDate) {
                      connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE));
                      connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString()));
                  }
                  if (workingDirectory.HasOverrideDirectory) {
                      connection.SubmitRequest (
                          new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY));
                      connection.SubmitRequest (
                          new ArgumentRequest (workingDirectory.OverrideDirectory));
                  }

                  connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName));

                  connection.SubmitRequest(new DirectoryRequest(".",
                                          workingDirectory.CvsRoot.CvsRepository +
                                          "/" + workingDirectory.ModuleName));

                  connection.SubmitRequest(new CheckoutRequest());
                  Manager manager = new Manager (connection.Repository.WorkingPath);
                  if (LOGGER.IsDebugEnabled) {
                      LOGGER.Debug ("looking for directories to add to the " +
                                  "entries file in=[" +
                                  this.workingDirectory.WorkingPath + "]");
                  }
              }
      -------------------------------

      Clayton, can you help to check it? thanks, thanks, and thanks.

      Gary,

       
    • Clayton Harbour

      Clayton Harbour - 2005-01-14

      Hi Gary, I released a development package at the following link:
          http://sourceforge.net/project/showfiles.php?group_id=78334&package_id=140980

      The source package contains the example application and numerous fixes.  If you could download and try against your code base that would be great. 

      Cheers,

      Clayton

       
      • cvsclient

        cvsclient - 2005-01-14

        hi Clayton,

        thanks for your great efforts and contribution on this library.

        i will chekout the development package and develop my cvs client on it.

        thanks again.

        Gary,

         

Log in to post a comment.