Home Forums HTBasic Forum about call dll-C and CSharp

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9368
    Dongxu Li
    Participant

      Hello Sir,
      I have an issue during call dll with HTBasic version v9.20. The program is like below. CppCLINETAssemblyWrapper.dll is programmed by C. I can DLL LOAD and DLL GET in CppCLINETAssemblyWrapper.dll successfully. In this CppCLINETAssemblyWrapper.dll it calls another dll(programmed by CSharp, all source code are in CSharp dll,CppCLINETAssemblyWrapper.dll just an interface to HT Basic). Then it is crashed during call FNHtb_cropto(String_in2$,String_in$,Ret$,Ok).
      Could you please tell me if this method is ok or not? HT Basic—>dll(C program)—>dll(CSharp program)
      thanks a lot.

      DLL UNLOAD ALL
      DIM Org_msi$[999]
      DIM Ret$[256],String_in$[256],String_in2$[256]
      INTEGER Ret,Ok
      Org_msi$=SYSTEM$(“MSI”)
      MASS STORAGE IS “D:\DLL_frames\”
      DLL LOAD “CppCLINETAssemblyWrapper”
      DLL GET “SHORT CppCLINETAssemblyWrapper:BTBasic_DLL_Call” AS “Htb_cropto”
      IF NOT POS(SYSTEM$(“VERSION:HTB”),”RUNTIME”) THEN LIST DLL
      String_in$=”3|2|1″
      String_in2$=”Sum”

      Ret=FNHtb_cropto(String_in2$,String_in$,Ret$,Ok) !call another dll(C sharp programed)

      END

      public int BTBasic_DLL_Call(string functionName, string parameters, ref string returnString, ref int returnNumber)

      #9369
      Dongxu Li
      Participant

        Hello,
        I update my question to make you better understand.
        BASIC language programs need to call a class library written in C#. We created an intermediate DLL with a C language interface using C++/CLI. BASIC program—>dll(C++/CLI with C interface)—>dll (C# program). This solution works fine on ICT devices with BT BASIC , but fails to execute on programs written in HT BASIC language. Any suggestions on what to do?
        thanks a lot.

        #9370
        PatB
        Moderator

          Hi Dongxu,

          I setup a similar test where I created an unmanaged C++ dll and from it called into a managed C# dll. Loading the unmanaged C++ dll from HTBasic and calling the unmanaged function that calls into the managed dll, I was able to reproduce the same exception you are seeing. I have spent some time looking into it and finally found a solution. There were two steps I needed to take before i was able to call the unmanaged dll function from HTBasic successfully.

          First, make sure that your unmanaged DLL and Managed DLL are both targeting x86 since that is what HTBasic targets.

          Second, put the managed dll into the same folder that the HTBwin.exe file is in.

          Hopefully this will allow it to work for you.

          Thanks,

          Pat

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.
        Scroll to Top
        HTB icon

        Please Sign In