Exception Handling in the .NET SDK

 
0 Likes

The C#.NET SDK is a layer of classes which wrap around the core set of J#.NET SDK core classes.

When developing custom SDK applications using C#.NET, one must include the assemblies StarTeam.dll (the C# layer) and StarTeam.Core.dll (the J# layer)

All C# SDK exceptions derive from System.Exception. At a minimum, handling an SDK Exception requires catching System.Exception, and reporting the details via Exception.ToString()

as an example...

StarTeam.Server s = null;
try
{
     s = new StarTeam.Server("localhost", 49201);
     s.Connect();
     s.LogOn("Administrator", "Administrator");
     StarTeam.Project p = s.FindProject("Project");
     StarTeam.View vP = p.DefaultView;
     StarTeam.View vC = p.FindView("child");
     StarTeam.ViewCompareMerge.Session n = new

      StarTeam.ViewCompareMerge.Session(StarTeam.ViewCompareMerge.MergeType.REBASE, vP, vC);

       n.Compare();
}
catch (System.Exception ex)
{
      MessageBox.Show(ex.ToString());
}

finally {
    s.Disconnect();

}

Labels:

How To-Best Practice
Comment List
Related
Recommended