Announcement

Collapse
No announcement yet.

Developer help!

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

    Developer help!

    Ok, I feel really stupid, but I am stuck. I've never tried to create a DLL that I can reference from my own scripts until now, so I'm probably missing something simple.

    I've got a DLL (say, Snevl.dll) that I've built and put in /bin/Snevl.

    In settings.ini, I've added this to the end of the "ScriptingReferences="

    Snevl;C:\Program Files\Homeseer 2\Bin\Snevl\Snevl.dll

    In my VB.NET script, my first line is:

    IMPORTS Snevl

    When I try and run the script, I get this in the error log (with lots of other stuff):

    Scripting runtime error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Snevl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=edf3d6c92ee55902' or one of its dependencies.

    Go ahead, make me feel stupid. What am I doing wrong?

    Steve
    Last edited by stevea; January 9, 2010, 12:05 PM. Reason: fixed typo

    #2
    I struggled with this also. Not sure I have an answer but some clues.

    Most of the entry for namespace have a format of xxx.xxx. In mine I had to put in the following entry

    Code:
    jvFunctions.jvFunctions;jvFunctions.dll,
    and if you look at the other entries they are similar.
    James

    Running HS 3 on Win10 .

    Comment


      #3
      Originally posted by jasv View Post
      Most of the entry for namespace have a format of xxx.xxx.
      James,

      So are you saying that in my case I need the scripting references to have this?

      Snevl.Snevl;C:\Program Files\Homeseer 2\Bin\Snevl\Snevl.dll

      If that's the case, in my script do I change the Imports line to reference Snevl.Snevl, instead of just Snevl?

      I just want to make sure I understand what you are saying...

      Steve

      Comment


        #4
        Have a look at the ScriptingReferences doc: http://www.homeseer.com/support/home...namespaces.htm

        And this post: http://board.homeseer.com/showthread...tingreferences
        Best regards,
        -Mark-

        If you're not out on the edge, you're taking up too much room!
        Interested in 3D maps? Check out my company site: Solid Terrain Modeling

        Comment


          #5
          Thanks Mark, but I think I'm doing exactly what those say.

          Of note, the error message includes the PublicKeyToken for the library I built, which only exists in the DLL itself. I think that means that the scripting engine has found the library file, but...

          That would also seem to indicate that the reference I put in ScriptingReferences is working, otherwise I don't think it would know to look in that directory.

          Steve

          Comment


            #6
            Originally posted by stevea View Post
            James,

            So are you saying that in my case I need the scripting references to have this?

            Snevl.Snevl;C:\Program Files\Homeseer 2\Bin\Snevl\Snevl.dll

            If that's the case, in my script do I change the Imports line to reference Snevl.Snevl, instead of just Snevl?

            I just want to make sure I understand what you are saying...

            Steve
            In my case I did not have to do any imports at all.
            James

            Running HS 3 on Win10 .

            Comment


              #7
              Here is the code of my DLL

              PHP Code:
              Option Explicit On
              Option Strict On

              'MS VB 2005 Express HS Plugin Global References
              '
              Fuego 12th Jul2005
              'Version 1.0.0

              '
              .NET References needed in project:
              '(Use Menu: Project, Add Reference, Browse ...)
              '
              HomeSeer2 c:\Program Files\HomeSeer 2\HomeSeer2.dll
              'Scheduler - c:\Program Files\HomeSeer 2\Scheduler.dll

              '
              Edit C:\Program Files\HomeSeer 2\Config\settings.ini
              'to include and additional assemblies needed. e.g.
              '
              ScriptingReferences = ... ,globalplug.globalplug;globalplug.dll, ...

              'To use within scripts, just reference the members of globalplug.SA, e.g.:
              '
              globalplug.SA.Name()
              'The above assumes that you compiled the library with a project namespace
              '
              of nullotherwise you'll need to type project.class.member
              '
              i.eglobalplug.globalplug.SA...

              Imports System
              Imports System
              .IO
              Public Class jv_ScriptFunctions

                  
              Private Const ThisLibName As String "jvFunctions"
                  
              Public Shared ReadOnly Property jvProperty() As String
                      Get
                          
              Return "jvProperty was successfull"
                      
              End Get
                  End Property
                  
              Public Shared Function GetFunction() As String
                      
              Return "GetFunction was succesful"
                  
              End Function
              End Class 
              Here is the code in my script.

              PHP Code:

              'Imports jvESS.jvESS_Functions
              Module HS_Script_jvtest2

                  Sub Main(ByVal Parm As Object)
                      Try
                          MsgBox("Test = " & jv_ScriptFunctions.jvProperty)
                          Exit Sub
                      Catch ex As Exception
                          MsgBox("jvtest2.vb," & "error = " & ex.Message)
                      End Try
                  End Sub
              End Module 
              I used this to test everything out before I created the dll I am using.
              James

              Running HS 3 on Win10 .

              Comment


                #8
                An update:

                I think I've figured out that my ScriptingReference is right, but I must have built the library wrong.

                I did nothing but change the IMPORTS statement in my script to something that doesn't exist, e.g.:

                IMPORTS HeckAndGone

                I think the script engine will now look for a class called "HeckAndGone" through the libraries in the scripting references. But, instead of an error saying it can't find it, I get the same error message before: That it can't find / open the . So I think that the scripting reference must be right, because it attempting to read the DLL, and in fact is picking up the correct version and public key from DLL.

                I don't know a thing about the Microsoft development environment, so I probably did something wrong in trying to create the DLL. I have a AssemblyInfo file in it that defines the AssemblyTitle, CLSCompliant(True), a version, and a public / private key file. It all builds a DLL without errors. Is there something obvious that I'm missing?

                Steve

                Comment


                  #9
                  Originally posted by jasv View Post
                  Here is the code of my DLL ...
                  James,

                  A stupid question I'm sure, but... Where do you put your DLL for runtime? I know it's bad form to put it in the root Homeseer directory, so I put it in the Bin subdirectory, but there are not any others there.

                  Steve

                  Comment


                    #10
                    I didn't think twice about putting it the homeseer root directory. It is where the custom plugins go so I thought it couldn't hurt but maybe I am wrong.
                    James

                    Running HS 3 on Win10 .

                    Comment


                      #11
                      Did you regsvr32.exe on the dll file?
                      huggy_d1

                      Automating made easy

                      Comment


                        #12
                        Originally posted by huggy_d1 View Post
                        Did you regsvr32.exe on the dll file?
                        Since this is .NET, I thought I had to do a regasm instead (which I did), but I'll do the regsvr32 as well. Thanks for the suggestion.

                        Steve

                        Comment

                        Working...
                        X