Announcement

Collapse
No announcement yet.

Scripting + C# + loading assembly = failure

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

    Scripting + C# + loading assembly = failure

    I have to be doing something wrong but searches for a solution yields null...

    I have events executing C# scripts which must load namespaces/types from my own class library. I am unable to make this work.
    As I have learned:
    • Config.ini's ScriptingReferences setting only pertains to VB script. So don't even bother using this
    • To load/import types from an assembly DLL you must add a line to the C# script:
      //css_reference <your_dll>;

    So, my script now looks like this:
    Code:
    //css_reference AVRControler.dll;
    using AVRControler;
    public object Main( string myParamText)
    {
        AVRControler.CAVR myAvr = new AVRControler.CAVR();
        hs.WriteLog("xxxx", "Woo Hoo!");
        return( true );
    }

    I copied the AVRControler.dll file into my HS4 root, <HS4 root>\scripts and <HS4 root>\bin\homeseer for good measure. Still fails with error:
    {interactive}(25,9): error CS0246: The type or namespace name `AVRControler' could not be found. Are you missing a using directive or an assembly reference?

    Details of the class library assembly:
    • .Net Framework v4.6.2
    • C#
    • Built for "any cpu"
    Question: What am I missing/not understanding here? The documentation is vague and piecemeal so it may be that I didn't read the right documents.


    #2
    ...I have even tried adding the assembly as a dependency in HS4.exe.config. No joy. I am lost in how HS3/4 works with all of this. The learning curve certainly stunts my progress using this platform. Any assistance is appreciated.

    Comment


      #3
      Sorry, but the C# scripting does not work very well. I have tried several times but it seems they are using an old scripting engine.
      I have done most of my scripts in vbscript since it seems to work a bit better.

      Comment


        #4
        Try the suggestions made starting at post #5 of this C# Script Question - HomeSeer Message Board seems like you have to have full name references.

        FWIW, "css_reference" site:forums.homeseer.com in google will provide a number of hits.

        Comment


          #5
          Thanks, mterry63. My google/bing/forum searches already yielded the same question I am asking with no answers. For a platform as well known as HomeSeer I am disappointed that the capabilities and documentation are so anemic and chaotic. At this point I am beginning to regret moving to this platform. My previous platform (Vera) had a vibrant community and I could locate answers to me questions.

          How do we get visibility to the developers? I work at a professional software company and I gotta say that this platform feels like it is less than professionally written/supported. I would expect to have some of the dev/PM team looking over these forums.

          The support in the platform for VB seems pretty robust. I trust that the support for C# which the docs elude to has been tested & validated. All we need is to know, definitively, how to use it.

          Comment


            #6
            As I said before (unless they have upgraded in HS4): The c# scripting engine in HomeSeer is an old one. It makes scripting in C# a pain. After trying with a couple of scripts I switched reluctantly to VBScript. C# is my day to day coding language, but I have given up creating C# scripts.

            But writing plugins is something you can do in C#. So far I have written 9 plugins for HS3. You can get them on our norwegian home automation forum (https://www.hjemmeautomasjon.no/forums/forum/46-plugins/)

            Comment

            Working...
            X