Hi,
There is an error in your sample program. It should be like this:
CaWHarvest harvest = new CaWHarvest();
int res = harvest.Login("broker", "harvest", "harvest");
Console.WriteLine(res);
CaWContainer container = harvest.GetProjectList();
// CaWStringList stringList = container.GetKeyList();
int projectCnt = container.GetKeyElementCount("CA_ATTRKEY_NAME") - 1;
// for (int i = 0; i <= stringList.GetSize(); i++)
for (int i = 0; i <= projectCnt; i++)
{
CaWData data = container.Props("CA_ATTRKEY_NAME", i);
if (data.GetStringValue().Trim().Length > 0)
Console.WriteLine("Project Name : " + data.GetStringValue());
}
Br
Tomasz Grzmilas
------------------------------
Developer
Delegate
------------------------------
Original Message:
Sent: 10-21-2020 12:05 PM
From: Sridhar Gooni
Subject: Installing Chsdk on Windows 10 and Usage in C# project
Hello Tomasz,
Can you try following sample program?
Following is the sample program which i have used to print project names :
CaWHarvest harvest = new CaWHarvest();
int res = harvest.Login("broker", "harvest", "harvest");
Console.WriteLine(res);
CaWContainer container = harvest.GetProjectList();
CaWStringList stringList = container.GetKeyList();
for (int i = 0; i <= stringList.GetSize(); i++)
{
CaWData data = container.Props("CA_ATTRKEY_NAME", i);
if (data.GetStringValue().Trim().Length > 0)
Console.WriteLine("Project Name : " + data.GetStringValue());
}
Thanks,
Sridhar
Original Message:
Sent: 10-19-2020 09:34 AM
From: Tomasz Grzmilas
Subject: Installing Chsdk on Windows 10 and Usage in C# project
Hi,
I use Windows 10 64 bit version.
I register chsdk.lib from 32 bit installation.
In my program I have:
ICaWHarvest harvest = new CaWHarvest();
var res = harvest.Login("brocker", "user", "login");
I get error
System.InvalidCastException
HResult=0x80004002
Message=Unable to cast COM object of type 'CHSDKLib.CaWHarvestClass' to interface type 'CHSDKLib.ICaWHarvest'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{70107C61-8ABB-11D5-961B-0010A4F73DE4}' failed due to the following error: Bad variable type. (0x80020008 (DISP_E_BADVARTYPE)).
Source=System.Private.CoreLib
StackTrace:
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at CHSDKLib.CaWHarvestClass.Login(String bstrBrokerName, String bstrUserName, String bstrPassword)
Can you tell what is the problem ?
Original Message:
Sent: 08-31-2020 06:33 AM
From: Sridhar Gooni
Subject: Installing Chsdk on Windows 10 and Usage in C# project
Hello Chris,
Can you try copying chsdk.dll and chsdk.lib from 32 bit installation?
The above step should solve your problem.
Thanks,
Sridhar