Unable to cast object of type 'SourceItem' to type 'RenamedSourceItem'

May 16, 2009 at 12:23 AM

I'm not sure if I'm the only one seeing this, but I setup SvnBridge (server), and when I try to view the log for a particular branch or use this branch as part of a merge, I receive the exception: "Unable to cast object of type 'CodePlex.TfsLibrary.ObjectModel.SourceItem' to type 'SvnBridge.SourceControl.RenamedSourceItem'." I can upload the error log file if needed, but I'm just wondering if I setup something wrong.

Jul 3, 2009 at 12:12 PM

I'm getting the same error here

 

Time     : 3/07/2009 13:09:15
Message  : Unable to cast object of type 'CodePlex.TfsLibrary.ObjectModel.SourceItem' to type 'SvnBridge.SourceControl.RenamedSourceItem'.
User     : TFSBESERV
Request  : REPORT http://192.168.2.14:8081/!svn/bc/3609/PROJECTNAME
<?xml version="1.0" encoding="utf-16"?>
<log-report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="svn:">
  <discover-changed-paths />
  <end-revision>3609</end-revision>
  <path />
  <start-revision>0</start-revision>
</log-report>

Exception:
   System.InvalidCastException: Unable to cast object of type 'CodePlex.TfsLibrary.ObjectModel.SourceItem' to type 'SvnBridge.SourceControl.RenamedSourceItem'.
   at SvnBridge.Handlers.ReportHandler.LogReport(TFSSourceControlProvider sourceControlProvider, LogReportData logreport, String path, TextWriter output)
   at SvnBridge.Handlers.ReportHandler.Handle(IHttpContext context, TFSSourceControlProvider sourceControlProvider)
   at SvnBridge.Handlers.RequestHandlerBase.Handle(IHttpContext context, IPathParser pathParser, NetworkCredential credentials)
   at SvnBridge.Net.HttpContextDispatcher.Dispatch(IHttpContext connection)
   at SvnBridgeServer.SvnBridgeHttpHandler.ProcessRequest(HttpContext context)

Stack Trace:
   at SvnBridge.Handlers.ReportHandler.LogReport(TFSSourceControlProvider sourceControlProvider, LogReportData logreport, String path, TextWriter output)
   at SvnBridge.Handlers.ReportHandler.Handle(IHttpContext context, TFSSourceControlProvider sourceControlProvider)
   at SvnBridge.Handlers.RequestHandlerBase.Handle(IHttpContext context, IPathParser pathParser, NetworkCredential credentials)
   at SvnBridge.Net.HttpContextDispatcher.Dispatch(IHttpContext connection)
   at SvnBridgeServer.SvnBridgeHttpHandler.ProcessRequest(HttpContext context)

Headers:
   Connection=TE, Keep-Alive
   Content-Length=250
   Content-Type=text/xml; charset="utf-8"
   Accept-Encoding=gzip, svndiff1;q=0.9,svndiff;q=0.8
   Authorization=Basic VEZTQkVTRVJWOkFiYzEyMy4=
   Host=192.168.2.14:8081
   TE=trailers
   User-Agent=SVN/1.5.4 SVNKit/1.2.1 (http://svnkit.com/) r5297

Jul 3, 2009 at 1:09 PM

I had the same problem and changed the code in the ReportHandler in the method LogReport to:

     else if ((change.ChangeType & ChangeType.Rename) == ChangeType.Rename)
{

var renamedItem = new RenamedSourceItem(change.Item, change.Item.RemoteName, change.Item.RemoteChangesetId);
output.Write("<S:added-path copyfrom-path=\"/" + Helper.EncodeB(renamedItem.OriginalRemoteName) +
"\" copyfrom-rev=\"" + renamedItem.OriginalRevision + "\">/" +
Helper.EncodeB(change.Item.RemoteName) + "</S:added-path>\n");
output.Write("<S:deleted-path>/" + Helper.EncodeB(renamedItem.OriginalRemoteName) +
"</S:deleted-path>\n");
}
else if ((change.ChangeType & ChangeType.Branch) == ChangeType.Branch ||
(change.ChangeType & ChangeType.Merge) == ChangeType.Merge)
{

var renamedItem = new RenamedSourceItem(change.Item, change.Item.RemoteName, change.Item.RemoteChangesetId);
output.Write("<S:added-path copyfrom-path=\"/" + Helper.EncodeB(renamedItem.OriginalRemoteName) +
"\" copyfrom-rev=\"" + renamedItem.OriginalRevision + "\">/" +
Helper.EncodeB(change.Item.RemoteName) + "</S:added-path>\n");
}

Aug 24, 2009 at 11:04 PM

Thanks for the post. I got the latest code from the repository, compiled, and tried it again, and it looks like it is fixed now.