Announcement

Collapse
No announcement yet.

DLL and VB.Net

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DLL and VB.Net

    I have seen the postings about calling a C++ based DLL from an EFS script. I have generated a DLL using VB.Net 2005 with a simple test function that has no input parameters and returns an integer.

    I have tried calling it using the simple script below, but it cannot find the function. I get the error "Internal Error: DLL ("C:\Dev\Class1\bin\Release\Class1.dll"), Function(test) was not found"

    Are there any DLL examples using vb?

    Trevor

    ======================
    var Title = "DLLTest"

    var d = new DLL("C:\\Dev\\Class1\\bin\\Release\\Class1.dll");
    d.addFunction("mycall", DLL.INT, DLL.STDCALL, "test");

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("Sample");

    var v = d.call("mycall");
    debugPrint("v = " + v + "\n");
    }


    function main() {
    }

  • #2
    without seeing your dll code.. I believe this is the problem..

    ======================
    var Title = "DLLTest"

    var d = new DLL("C:\\Dev\\Class1\\bin\\Release\\Class1.dll");
    d.addFunction("Test", DLL.INT, DLL.STDCALL, "test");

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("Sample");

    var v = d.call("Test");
    debugPrint("v = " + v + "\n");
    }


    function main() {
    }
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Still no luck. The error message in the formula window indicates it is opening the DLL and resolving the ref name to the correct the function name (e.g. test) but it cannot find the specific function inside the DLL. I have tried a few combinations but no luck.

      I have seen examples of c++ generated DLL's, has amyone tried this with VB 2005 generated DLL's?

      Any help on this would be appreciated.

      Here is the VB.Net 2005 code.

      The vb namespace is ClassLibrary1 and the dll built is ClassLibrary1.dll

      The VB code is:

      Public Class Class1
      Public Function test(ByVal num As Integer) As Integer
      Return num * 2
      End Function
      End Class

      The efs script is this:

      var d = new DLL("ClassLibrary1.dll");
      d.addFunction("Test", DLL.INT, DLL.STDCALL, "test", DLL.INT);

      function preMain() {

      setPriceStudy(true);
      setStudyTitle("Sample");

      var v = d.call("Test", 2);
      debugPrint("v = " + v + "\n");
      }


      function main() {
      }

      Comment


      • #4
        I don't work in Visual Basic - so I'm at a loss there. My programmers and I work mostly in Visual Studio (c#).

        Other than the fact that you're trying to do everything in Premain(), it looks like it should work.

        Do you get any error messages in EFS? If not, then it called the DLL (or tried to).

        Do you see your "debugPrintln()" output in the FOW (formula output window)?? If not, then the dll BOMBED and this could be because of errors in the DLL or errors in your definition of the dll functions.

        I know it's frustrating, but at this point I can't offer much more help unless you wanted my programmers to fix it for you (which would cost a little bit). I'm trying to help, but like I said I don't do much with VB.
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          VB.net, C# -- under the hood it is all the same (CIL).

          A question would be: has anyone ever gotten a .net dll to work? It is not clear to me how managed code is supposed to work in eSignal. You might have to write an old style dll for unmanaged applications. Someone out there probably knows the answer to this.

          Comment


          • #6
            yes. my programmers have gotten .NET dlls to work with esignal. We use .NET for my MENT Trader Services application.
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              I get the same error message when compiling the efs.

              Formula Output window says it can't find the function in the dll. I've written the dll in C# and when I open the dll in the C# editor, you can see the function name there. So the function exists, there seem to be some problem with what esignal is looking for.

              Anyone found the solution to this problem yet?

              The dll has a function that takes 2 ints and adds them together.
              Very simple dll, but esignal doesn't recognize the "Add" function in my dll.

              var d = new DLL("C:\\testDll\\BWInterface.dll");
              d.addFunction("MyCallName", DLL.INT, DLL.CDECL , "Add", DLL.INT, DLL.INT);

              function main()
              {
              if (getBarState() == BARSTATE_ALLBARS)
              {
              debugPrintln(d.call("MyCallName", 5, 7));
              }
              }

              Comment


              • #8
                I asked the same question few months ago here is the link for that thread:



                Please let me know how people at esignal were able to accomplish this call a managed DLL.

                thanks

                BG
                Tony Gof

                Comment


                • #9
                  eSignal supports C++ or VB6 for this object. Other programming languages may be used, but are not supported by eSignal. If no other users are able to offer help with .net dlls here, please consider contacting one of our EFS Consultants for possible assistance.
                  Jason K.
                  Project Manager
                  eSignal - an Interactive Data company

                  EFS KnowledgeBase
                  JavaScript for EFS Video Series
                  EFS Beginner Tutorial Series
                  EFS Glossary
                  Custom EFS Development Policy

                  New User Orientation

                  Comment


                  • #10
                    After doing some web searches and playing around, I got the following to work with C#. Should also work for any language that produces IL code.

                    Here is my C# code:
                    PHP Code:
                    public static class Class1
                    {
                        public static 
                    int TestFunction(int a)
                        {
                            return (
                    1);
                        } 
                    // end of TestFunction

                    This was compiled as a class library in VS2005. I then followed the directions here
                    and created a file called Test.dll which I put in the FormulaOutput directory.

                    Heres the efs code I used.
                    PHP Code:
                    try{
                    var 
                    = new DLL("C:\\Program Files\\eSignal\\FormulaOutput\\Test.dll");
                    d.addFunction("MyCallName"DLL.INTDLL.CDECL "TestFunction"DLL.INT);
                    }catch(
                    e){debugPrintln(e);}

                    function 
                    main()
                    {
                        if (
                    getBarState() == BARSTATE_ALLBARS)
                        {
                            
                    debugPrintln(d.call("MyCallName"5));
                        }

                    Running this printed 6 in the Formula Output Window.

                    I didn't use a namespace to simplify things. But it should still work if you use a namespace.

                    This method is a bit of a kludge, but it does work.

                    Steve

                    Comment


                    • #11
                      I tried all the steps given and my "HelloWorld" function crashed eSignal! Perhaps because I am running VS 2008? Which ilasm.exe version should be used? I used the one in my framework v2.0.50727 folder.

                      Is there an updated/simpler way to accomplish this? I am just looking to call a DLL and do some processing via compiled code. If I just build and try and call it "as-is" I get an EFS error about the function not being found ("Function(HelloWorld) was not found").

                      I find that no matter how much I tweak and improve my EFS code's performance, eSignal locks up badly during high volume times (sometimes 5-20 minutes!). If I can unload some of this processing to compiled code, perhaps I can see less/shorter locking.

                      Thanks!
                      Daniel
                      Last edited by neoikon; 11-24-2008, 12:54 PM.
                      eSignal File Share: http://share.esignal.com/groupcontents.jsp?groupid=1130

                      Comment


                      • #12
                        Hi Daniel,

                        I've not pursued DLLs based on my understanding that there are interface issues between the eSignal JavaScript Framework and the Visual Studio .NET framework.

                        I've heard C++ dlls work well, but this is the extent of what I have heard.

                        Comment

                        Working...
                        X