Announcement

Collapse
No announcement yet.

Adding DLL and ScriptingReferences

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

    Adding DLL and ScriptingReferences

    Hi,

    I want to use the SnmpSharpNet.dll but I don't know what to add in the ScriptingReferences line.
    I've placed the dll in the root and added SnmpSharpNet.dll in the scripting reference but that doesn't work.

    How do I know what to add in the line if I want to use the DLL?

    #2
    can you post your ScriptingReferences= line
    tenholde

    Comment


      #3
      Originally posted by tenholde View Post
      can you post your ScriptingReferences= line
      You're right with the error in the ScriptingReferences. I had everything semicolon separated instead of comma.

      Jon00 pointed out the same in a pm
      ScriptingReferences=System.Web.Script.Serialization;System.W eb.Extensions.dll;SnmpSharpNet;SnmpSharpNet.dll
      should be
      ScriptingReferences=System.Web.Script.Serialization;System.W eb.Extensions.dll,SnmpSharpNet;SnmpSharpNet.dll

      However I run in another wall
      Sep-27 22:02:37 Error Compiling script /opt/HomeSeer/scripts/Test/test.vb: 'Dictionary' is not declared. It may be inaccessible due to its protection level.
      Sep-27 22:02:37 Error Compiling script /opt/HomeSeer/scripts/Test/test.vb: The import 'System.Core' could not be found.
      The SnmpSharpNet webpage says I also need the 'Imports System' in the script but when I do that I get this error.

      Code:
      Compiling script /opt/HomeSeer/scripts/Test/test.vb: Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.7 - tarball) Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved. /tmp/11lsjvxb.0.vb (2,16) : warning VBNC40056: The import 'System.Core' could not be found. vbnc : Command line : error VBNC99999: Unexpected error: Object reference not set to an instance of an object at vbnc.TypeNameResolutionInfo.CheckImports (System.String R, vbnc.ImportsClauses Imports, System.Int32 TypeArgumentCount, System.Boolean& wasError) [0x002c2] in :0 at vbnc.TypeNameResolutionInfo.ResolveUnqualifiedName (System.String[] Rs, System.Int32 TypeArgumentCount) [0x000c3] in :0 at vbnc.TypeNameResolutionInfo.Resolve () [0x003e7] in :0 at vbnc.TypeNameResolutionInfo.Resolve () [0x001bf] in :0 at vbnc.QualifiedIdentifier.ResolveAsTypeName (System.Boolean AsAttributeTypeName, System.Int32 TypeArity) [0x0002b] in :0 at vbnc.SimpleTypeName.ResolveTypeReferences (System.Boolean AsAttributeTypeName) [0x0003d] in :0 at vbnc.SimpleTypeName.ResolveTypeReferences () [0x00001] in :0 at vbnc.NonArrayTypeName.ResolveTypeReferences () [0x00037] in :0 at vbnc.CatchStatement.ResolveTypeReferences () [0x00019] in :0 at vbnc.Helper.ResolveTypeReferencesCollection (System.Collections.IEnumerable Collection) [0x00037] in :0 at vbnc.BaseObjects`1[T].ResolveTypeReferences () [0x00001] in :0 at vbnc.TryStatement.ResolveTypeReferences () [0x00019] in :0 at vbnc.CodeBlock.ResolveTypeReferences () [0x000bd] in :0 at vbnc.MethodBaseDeclaration.ResolveTypeReferences () [0x00090] in :0 at vbnc.MethodDeclaration.ResolveTypeReferences () [0x00007] in :0 at vbnc.SubDeclaration.ResolveTypeReferences () [0x00048] in :0 at vbnc.AssemblyDeclaration.ResolveTypeReferences (vbnc.TypeDeclaration Type) [0x000c4] in :0 at vbnc.AssemblyDeclaration.ResolveTypeReferences () [0x0003c] in :0 at vbnc.Compiler.Compile_Resolve () [0x00165] in :0 at vbnc.Compiler.Compile () [0x004c7] in :0 Compilation took 00:00:00.5434050
      I also tried to add the System.Core.dll in the root of HS3 and add the following in the ScriptingReferences System.Core;System.Core.dll but when I do that all my plugins won't load.

      Comment


        #4
        From this post
        https://forums.homeseer.com/forum/de...n-tenscripting

        Originally posted by sparkman View Post

        HS automatically imports System.Core and typically throws that error message if there is something else wrong in a script. It appears to be an issue related to the declaration of “List”.
        Back to the drawing board. I used the example given on the sharp Snmp website but somehow HomeSeer doesn't like that.

        Comment


          #5
          Dictionary is in the system.collections.generic namespace
          tenholde

          Comment


            #6
            Must be added to scriptingreferences
            tenholde

            Comment


              #7
              I read here that you add
              Imports System.Collections.Generic
              on top of the script that is could work but in my case is doesn't.
              But do you mean with adding it to scriptingreferences?
              Like ScriptingReferences=System.Collections.Generic ?

              Comment


                #8
                I've added
                ScriptingReferences=System.Web.Script.Serialization;System.W eb.Extensions.dll,SnmpSharpNet;SnmpSharpNet.dll,System.Colle ctions.Generic;System.Collections.dll

                System.Collections.dll is in the HS3 root

                And
                Imports System.Collections.Generic
                Imports SnmpSharpNet

                Ont top of the script but I still see this error
                Sep-28 21:30:54 Error Compiling script /opt/HomeSeer/scripts/Test/test.vb: CHANGEME
                Sep-28 21:30:54 Error Compiling script /opt/HomeSeer/scripts/Test/test.vb: The import 'System.Core' could not be found.

                Comment


                  #9
                  Well, you've eliminated the Dictionary error. You can ignore the System.Core error, it is a catch all that means there is any error somewhere. What is CHANGEME ? Could you post the entire test.vb?
                  tenholde

                  Comment


                    #10
                    Yeah I don't know why that's there neither...

                    Here is the script I'm trying to run, it's the first part of another script from sharpsnmpnet website

                    Code:
                    Imports System.Collections.Generic
                    Imports SnmpSharpNet
                    
                    Sub Main(parm as object)
                    Try
                    Dim host As String = "192.168.148.101"
                    Dim community As String = "public"
                    Dim requestOid As String
                    Dim result As Dictionary(Of Oid, AsnType)
                    
                    requestOid = New String("1.3.6.1.4.1.9.9.13.1.3.1.7.1004")
                    Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
                    result = snmp.Get(SnmpVersion.Ver2, requestOid)
                    
                    Catch ex As Exception
                    hs.WriteLog("Warning", ex.Message)
                    End Try
                    
                    End Sub
                    Here is the original from SnmpSharpNet
                    Code:
                    Imports System
                    Imports SnmpSharpNet
                    Module Module1
                    Sub Main()
                    Dim host As String = "localhost"
                    Dim community As String = "public"
                    Dim requestOid() As String
                    Dim result As Dictionary(Of Oid, AsnType)
                    requestOid = New String() {"1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.2.0"}
                    Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
                    If Not snmp.Valid Then
                    Console.WriteLine("Invalid hostname/community.")
                    Exit Sub
                    End If
                    result = snmp.Get(SnmpVersion.Ver1, requestOid)
                    If result IsNot Nothing Then
                    Dim kvp As KeyValuePair(Of Oid, AsnType)
                    For Each kvp In result
                    Console.WriteLine("{0}: ({1}) {2}", kvp.Key.ToString(), _
                    SnmpConstants.GetTypeName(kvp.Value.Type), _
                    kvp.Value.ToString())
                    Next
                    Else
                    Console.WriteLine("No results received.")
                    End If
                    End Sub
                    End Module

                    It's this line that gives the error
                    result = snmp.Get(SnmpVersion.Ver1, requestOid)

                    Comment


                      #11
                      In the original code, requestOid is an array of strings
                      Dim requestOid() As String

                      In your code, it is just a string
                      Dim requestOid As String


                      In the original code, requestOid is set to an array with 2 string entries: "1.3.6.1.2.1.1.1.0" and "1.3.6.1.2.1.1.2.0"

                      In your code, requestOid is set to a single string: "1.3.6.1.4.1.9.9.13.1.3.1.7.1004"

                      The original code: result = snmp.Get(SnmpVersion.Ver1, requestOid)
                      Your code: result = snmp.Get(SnmpVersion.Ver2, requestOid)

                      Besides the different versions specified, what is snmp.Get expecting for its second parameter? In your call, you are passing a string; in the original call, it is passing an array of strings.
                      tenholde

                      Comment


                        #12
                        Jup that's it, the snmp.Get was expecting an string array and not a string.
                        Thanks a lot

                        Comment


                          #13
                          For anyone interested, here is the code for a simple SNMP get


                          Code:
                          Imports System.Collections.Generic
                          Imports SnmpSharpNet
                          
                          Sub Main(parm as object)
                          Try
                          Dim host As String = "192.168.148.101"
                          Dim community As String = "public"
                          Dim requestOid() As String
                          Dim result As Dictionary(Of Oid, AsnType)
                          requestOid = New String() {"1.3.6.1.2.1.1.1.0"}
                          Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
                          result = snmp.Get(SnmpVersion.Ver1, requestOid)
                          'result = snmp.GetNext(SnmpVersion.Ver1, requestOid)
                          
                          If Not snmp.Valid Then
                          hs.WriteLog("Script", "Invalid hostname/community")
                          Exit Sub
                          End If
                          
                          If result IsNot Nothing Then
                          Dim kvp As KeyValuePair(Of Oid, AsnType)
                          For Each kvp In result
                          hs.WriteLog("Script", kvp.Key.ToString())
                          hs.WriteLog("Script", SnmpConstants.GetTypeName(kvp.Value.Type))
                          hs.WriteLog("Script", kvp.Value.ToString())
                          Next
                          
                          Else
                          hs.WriteLog("Script", "No results received.")
                          End If
                          
                          
                          Catch ex As Exception
                          hs.WriteLog("Warning", ex.Message)
                          End Try
                          
                          End Sub

                          Comment

                          Working...
                          X