Harvest

 View Only
Expand all | Collapse all

Installing Chsdk on Windows 10 and Usage in C# project

  • 1.  Installing Chsdk on Windows 10 and Usage in C# project

    Posted Aug 26, 2020 10:35 AM

    Hello,
    in our company we upgraded to CA Harvest 13.0.3, because we are replacing old Windows 7 systems with newer Windows 10 platforms.
    On the old Windows 7 systems we have been using the CA Harvest SDK with the chsdk.dll file. So our setup included the registration of the chsdk.dll file with the the following command:
    regsvr32 chsdk.dll

    For this to work we had to copy the following files to the C:\Windows\SysWOW64 directory:
    chsdk.dll
    Hsdk.dll
    Hsdk.lib
    Hsdk64.dll
    Interop.CHSDKLib.dll

    In our C# project solution, we referenced the following COM->Type Library:
    chsdk 1.0 Type Library

    And inside the C# class we used:
    using CHSDKLib;

    So after upgrading to CA Harvest version 13.0.3, I checked the documentation for the usage of the COM Interface of the SDK:
    https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/business-management/harvest-scm/13-0/apis-and-sdk-reference/use-the-com-interface-of-the-software-development-kit-chsdk.html

    And that's where my problem starts. The file chsdk.dll no longer exists. I found chsdk64.dll in the installation directory, but not any of the files
    I used under Windows 7. I registered chsdk64.dll, but I could not find any COM->Type Library to include in my project. Having gone through the documentation provided, I could not find any help or more detailed instruction on how to do this. So hopefully somebody here can help me or point me in the right direction.




    ------------------------------
    Best Regards
    Christoph
    ------------------------------


  • 2.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Aug 27, 2020 01:18 PM
    Hi Christoph,

    We are reviewing this issue and will update you soon.


    Regards
    Paramesh


  • 3.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Aug 31, 2020 06:33 AM
    Hello Chris,

    Can you try copying chsdk.dll and chsdk.lib from  32 bit installation?

    The above step should solve your problem.

    Thanks,
    Sridhar


  • 4.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Aug 31, 2020 07:32 AM
    Hello Sridhar,
    thanks for the answer. Can you be a little more specific?
    In the old environment I have the following files:
    chsdk.dll
    Hsdk.dll
    Hsdk.lib
    Hsdk64.dll
    Interop.CHSDKLib.dll

    Following your hint, I copied them to C:\Windows\SysWOW64 and did the registration with admin rights (regsvr32 chsdk.dll) there. 
    Unfortunately this does not work. I get a registration error:
    Error when loading module C:\Windows\SysWOW64\chsdk.dll

    This error usually occurs, when the dll or any dependencies are not loadable or missing.

    In the old Windows 7 environment this step worked fine. But apparently not now.

    Just to be sure I also tried to copy everything to System32 and tried the registration there. I get the same error:
    Error when loading module C:\Windows\System32\chsdk.dll

    I believe that indicates that I cannot use the old chsdk.dll file from the CA Harvest 12.0 client.

    Best Regards
    Christoph







  • 5.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Aug 31, 2020 07:44 AM
    Hello Chris,

    From where did you copy the chsdk.dll?

    You need to copy the chsdk.dll and CHSDK.lib files from a machine which has 32 bit installation of Harvest 13.0.3.

    Let me know if you are not able to register them.

    Thanks,
    Sridhar


  • 6.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 02, 2020 05:05 AM
    Hello Sridhar,
    ok I have tried to get the chsdk.dll from a 32 bit installation and I copied it to the CA/SCM folder of the 64-bit client installation. Then I tried to register it with the regsvr32 command. It did not work. In my opinion this is logical, A 32-bit dll won't work in a 64-bit environment. When I install the 32-bit client version and register chsdk.dll there everything works fine.

    Unfortunately this is not a viable solution for us. We need the chsdk.dll registered in a 64-bit client environment.  I hope you have some ideas how to proceed.
    Thanks for your help so far.
    Best Regards
    Christoph Zill


  • 7.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Sep 02, 2020 09:32 AM
    Hello Chris,

    After registering 32 bit dll, was chsdk listed in COM Type library in visual studio.

    I was able to see in COM Type library.

    Did you copy CHSDK.lib file also?

    Thanks,
    Sridhar


  • 8.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 04, 2020 10:23 AM
    Hello Sridhar,
    it took me some time to try several configurations following your hints. In the C# code the initialization is done like this:

    Type comObj = Type.GetTypeFromProgID("Chsdk.CaWHarvest");
    LoadCaObject(comObj);

    This is what I found out:
    Config 1) Installed the 13.0.3 32-bit version. I checked the registry and noted that the chsdk.dll was already registered. So I did not need to run regsvr32.
    In the C# project the COM library was visible and the initialization of the CA Harvest session was possible.

    Config 2) Installed the 13.0.3 64-bit version. Again I checked the registry and noted that the chsdk.dll was already registered although there is no chsdk.dll file in the installation directory. But a chsdk64.dll is there. In the C# project the COM library was NOT visible and the project would not build.

    Config 3) same as above, but I copied the chsdk.dll (32-bit version) file and the CHSDK.lib (32-bit version) to the 64-bit installation directory. This time the COM library was visible and it would build. However I got an exception (file not found) when running the application at the:

    LoadCaObject(comObj);

    command.

    Config 4) same as above, but in additon I tried to register the 32-bit chsdk.dll file with regsvr32. This gave an error right away. I think that is logical because I tried to register a 32-bit version in an 64-bit environment.

    So my conclusion from this is, that most likely the chsdk64.dll file and the CHSDK64.lib file do not work, because of the naming. Could you maybe create a 64-bit library, but still call it chsdk.dll and CHSDK.lib?

    or do you have any other idea, what might be the problem?

    Best Regards
    Christoph


  • 9.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Sep 07, 2020 09:27 AM
    Hello Chris,

    You want to run the application in 64 bit mode or 32 bit mode?

    Also can you send the snippet you used to login.

    Thanks,
    Sridhar


  • 10.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Sep 07, 2020 12:18 PM
    Hello Chris,

    I have tried copying the following files from 32 bit installation to 64 bit installation

    1) chsdk.dll
    2) hsdk.dll
    3) CHSDK.lib

    Ran regsvr32 chsdk.dll. Registration was successful.

    Later on ran chsdk login call. It was successful.

    Thanks,
    Sridhar


  • 11.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 08, 2020 05:03 AM

    Hello Sridhar,
    our use case is, that we want to use the 64-bit client.

    I will now try your suggestion above. Number 2) is new. I will check it. Regarding the code snippet for login, 
    I never get to that part. As I wrote above, I fail when trying to load the COM-object.

    Best Regards
    Christoph




  • 12.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Sep 08, 2020 05:24 AM
    Hello Chris,

    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


  • 13.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 08, 2020 05:36 AM
    Hello Sridhar,
    my code looks very similar. I am a step further now. After copying Hsdk.dll as well, the regsvr32 chsdk.dll worked as well.
    I willl now check the project build. I will keep you informed.
    Best Regards
    Christoph


  • 14.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 08, 2020 05:41 AM
    Hello Sridhar,
    and another step. The COM-Type library is visible too and the C# project compiled in Visual Studio.
    I will now try to run the application in Debug Mode and check if the COM object loads.
    Bets Regards
    Christoph


  • 15.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Sep 08, 2020 05:46 AM
    Hello Sridhar,
    it looks very good now. The COM object loaded and CA Harvest could be initialized correctly.
    I will have to do some more testing now and in the following days, but I am now fairly optimistic, that it works.

    Copying Hsdk.dll did the trick.

    Thanks a lot for your patient support. I wish you all the best.
    Best Regards
    Christoph

    P.S.:
    I will give you another notice, when I am done with all my tests.


  • 16.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Sep 08, 2020 07:54 AM
    Hello Chris,
    Good to hear that.

    Thanks,
    Sridhar


  • 17.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 21, 2020 11:41 AM

    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 ?




  • 18.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Oct 21, 2020 12:05 PM
    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


  • 19.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 22, 2020 03:41 AM
    Hi,

    on Visual Studio 2019 v 16.8.0 preview 5 (.NET Core 5.0, .NET Core 3.1) this won't even compile :(


    On Visual Studio 2013 12.0.40629.00 update 5 (.NET Framework 4.8) I get the same error, as I wrote before, when hitting line:
    CaWHarvest harvest = new CaWHarvest();

    ------------------------------
    Developer
    Delegate
    ------------------------------



  • 20.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Oct 22, 2020 03:51 AM
    Hello Tomasz,

    I will check and update you on this.

    Can you confirm the following details:

    1) Harvest Version is V13.0.3 

    2) Visual Studio - 2019

    Thanks,
    Sridhar


  • 21.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 22, 2020 04:27 AM
    Hi,

    Yes:

    Harvest 13.0.3.152
    Visual Studio 2019 

    Br
    Tomasz Grzmilas

    ------------------------------
    Developer
    Delegate
    ------------------------------



  • 22.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Oct 22, 2020 06:53 AM
    Hello Tomasz,

    Can you try using windows form application type project? With windows form type, i am able to use the chsdk without any exceptions.

    I also got the same problem with console type application. I will check on this.

    Let me know what you find.

    Thanks,
    Sridhar


  • 23.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 22, 2020 07:23 AM
    Hi,

    Yes, with project types WindowsForm and WPF (.NET Framework) it works :)

    But with WPF and console app (.NET Core) don't :/

    It will be nice if this library works with .NET Core since .NET Framework will not be supported in future.

    Br
    Tomasz Grzmilas

    ------------------------------
    Developer
    Delegate
    ------------------------------



  • 24.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 22, 2020 10:42 AM
    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
    ------------------------------



  • 25.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Oct 22, 2020 11:52 AM
    Hello Tomasz,

    You are correct, i did not observe that.

    As of now, are you OK using windows form application type for using chsdk?

    Thanks,
    Sridhar


  • 26.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Oct 23, 2020 03:43 AM
    Hi,

    I prefer WPF application and .NET Core. Like I write before It will be nice if this library works with .NET Core since .NET Framework will not be supported in future.

    I start to write new application and I don't want to use old technology.

    Can we menage to chsdk works in .NET Core projects ?

    BR
    Tomasz Grzmilas


    ------------------------------
    Developer
    Delegate
    ------------------------------



  • 27.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Nov 30, 2020 04:07 AM
    Hi,

    One more thing, with COM library I can't do parallel programming :(

    Can you tell if CHSDK will be developed anymore ?

    BR
    Tomasz Grzmilas

    ------------------------------
    Developer
    Delegate
    ------------------------------



  • 28.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Broadcom Employee
    Posted Dec 04, 2020 03:49 AM
    Hi Tomasz Grzmilas,

    We are reviewing the question and in discussion with the product management.
    We will reach out to you for additional information on this 
    Regards,
    Balakrishna.


  • 29.  RE: Installing Chsdk on Windows 10 and Usage in C# project

    Posted Dec 04, 2020 03:54 AM
    Hi Balakrishna Shantamurthy,

    Great to hear that. If I can help please write.

    Br
    Tomasz Grzmilas

    ------------------------------
    Developer
    Delegate
    ------------------------------