How to create a C# .NET program that uses the Quality Center API?
Description:
This example adds a defect to a project using C# .NET.
Usage:
1. Select File -> New -> Project.
2. Select Console Application for template.
3. Give the project a Name.
Example:
AddDefect
4. In the menu, select Project -> Add Reference.
5. Navigate to the COM tab.
6. Select OTA COM 8.0 Type Library.
7. Click <OK>.
8. In the Solution Explorer tab, select the Class1.cs file.
9. Add the code below.
Code:
using System;
using TDAPIOLELib;
namespace AddDefect
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
TDConnectionClass td = new TDAPIOLELib.TDConnectionClass();
try
{
td.InitConnectionEx("http://<servername>/tdbin");
//Note: For Quality Center, connect by using the URL below:
td.InitConnectionEx("http://<servername>:port/qcbin");
td.ConnectProjectEx("DomainName","ProjectName","Username","Password");
}
catch
{
Console.WriteLine("Failed to connect to server.");
}
try
{
IBugFactory bfact = td.BugFactory as IBugFactory;
IBug mybug = bfact.AddItem("MyBug1")as IBug;
mybug.Summary = "This is a test.";
mybug.Status = "Open";
mybug.AssignedTo = "admin";
mybug.Post();
}
catch
{
Console.WriteLine("Failed to add defect.");
}
try
{
td.DisconnectProject();
td.ReleaseConnection();
}
catch
{
Console.WriteLine("Failed to disconnect server and/or project.");
}
}
}
}
I am not able to connect to the QC Server, getting an error such as "frec is missing a must attribute rbt_fp_effort_hours" . Please help me to solve this issue. I am using VS 2008 , is there any pre- requisite to connect to QC server through .net??
ReplyDeleteI am getting a Class not registered exception when instantiating TestSet class. I was getting the same COM exception for TDConnection, but that went away when I registered OTAClient.dll. What other DLLs do I need to register?
ReplyDeleteHi,
ReplyDeleteFollowing error thrown while creating connection object:
“Retrieving the COM class factory for component with CLSID {C5CBD7B2-490C-45F5-8C40-B8C3D108E6D7} failed due to the following error: 800703e6 Invalid access to memory location. (Exception from HRESULT: 0x800703E6).”