Announcement

Collapse
No announcement yet.

System.Net.Http cannot be found problem

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

    System.Net.Http cannot be found problem

    I'm trying to use HttpClient in a VB script (.vb extension). The script is (for now):

    Imports System.Net.Http
    Public Sub Main(ByVal param As Object)
    Dim client As HttpClient = New HttpClient()
    End Sub

    When I run this script from HS3, it doesn't compile. The HomeSeer log says:

    Apr-13 10:11:09 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Notify2.vb: Type 'HttpClient' is not defined.
    Apr-13 10:11:09 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Notify2.vb: Namespace or type specified in the Imports 'System.Net.Http' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
    Apr-13 10:11:09 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Notify2.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
    Can't figure out why HttpClient() can't be found. In another script, I use System.Net.WebClient and it runs just fine.

    Maybe I'm missing some DLL or other package that has HttpClient in it?

    Anyone have any tips? I am using HomeSeer version 3.0.0.548 in Windows 10 Pro - Work Station.



    #2
    You may need to install this: https://www.nuget.org/packages/Microsoft.Net.Http/

    Also read this: https://stackoverflow.com/questions/...-what-can-i-do
    Jon

    Comment


      #3
      Originally posted by jon00 View Post
      Thanks. I'm a bit confused whether to use Microsoft.Net.Http or System.Net.Http (some Google searches seemed to say Microsoft.Net.Http may be newer version, although the pages I found were somewhat dated). Well, my HomeSeer PC doesn't have either of them anyway (at least VB scripts that try to use them don't compile/run in HomeSeer). I'm wondering ithe .NET Core Runtime from https://docs.microsoft.com/en-us/dot...ots=os-windows has these and if so, I need to install the runtime?

      Comment


        #4
        I'll have to pass on that. Not sure how you could cross reference .NET core within the Homeseer environment. HS3 is compiled against .NET4 and you cannot reference against other .NET versions either. Why do you want to use HTTPClient anyway?
        Jon

        Comment


          #5
          Originally posted by jon00 View Post
          I'll have to pass on that. Not sure how you could cross reference .NET core within the Homeseer environment. HS3 is compiled against .NET4 and you cannot reference against other .NET versions either. Why do you want to use HTTPClient anyway?
          Yeah, installing .NET Core Runtime didn't help.

          Currently, I'm using System.Net.WebClient.UploadValues() to talk to Pushover so I can send Pushover notifications from a vb script. System.Net.WebClient works well (no compile problems) and is very simple (the main guts of the script is only half a dozen lines of code). I thought I'd update my script so it can also send an image. However, WebClient.UploadValues() doesn't support uploading an image and supplying metadata (such as user, token, etc.) at the same time. So, I thought I'd use HTTPClient using a function like discussed here: https://stackoverflow.com/questions/...in-c-sharp-net .

          But, HomeSeer compilation of my script fails since it can't find HttpClient. It finds System.Net.WebClient, but not System.Net.Http.HttpClient.

          Comment


            #6
            Just a guess, but try adding this to your ScriptingReferences setting in settings.ini (while HS is shut down):

            Code:
            System.Net.Http;System.Net.Http.dll
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              Originally posted by sparkman View Post
              Just a guess, but try adding this to your ScriptingReferences setting in settings.ini (while HS is shut down):

              Code:
              System.Net.Http;System.Net.Http.dll
              Yeah!! Changing settings.ini worked :-) . Thanks sparkman and jon00!!

              Comment

              Working...
              X