Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.Net Service Question

VB.Net Service Question

Scheduled Pinned Locked Moved Visual Basic
helpcsharpquestion
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tcombs07
    wrote on last edited by
    #1

    Hey guys, I have a quick question that I am hoping someone can answer for me. What I am trying to do is create VB.Net service that navigates to a page in the background every five minutes. What i am trying now is that i am using the Web Browser Control and in my start code i am using WebBrowser1.Navigate("URL Addres"), but once i go to install and run the service it gives me a Thread Exception error. Does anyone know the answer, please help because I have tried several things and none of which have worked. Thanks, Travis

    C V 2 Replies Last reply
    0
    • T tcombs07

      Hey guys, I have a quick question that I am hoping someone can answer for me. What I am trying to do is create VB.Net service that navigates to a page in the background every five minutes. What i am trying now is that i am using the Web Browser Control and in my start code i am using WebBrowser1.Navigate("URL Addres"), but once i go to install and run the service it gives me a Thread Exception error. Does anyone know the answer, please help because I have tried several things and none of which have worked. Thanks, Travis

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      A service generally doesn't have UI. It's hard to say more, without knowing what you've tried, what code causes the error, and what 'none of which have worked' means.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • T tcombs07

        Hey guys, I have a quick question that I am hoping someone can answer for me. What I am trying to do is create VB.Net service that navigates to a page in the background every five minutes. What i am trying now is that i am using the Web Browser Control and in my start code i am using WebBrowser1.Navigate("URL Addres"), but once i go to install and run the service it gives me a Thread Exception error. Does anyone know the answer, please help because I have tried several things and none of which have worked. Thanks, Travis

        V Offline
        V Offline
        Vivek Narayanan
        wrote on last edited by
        #3

        goto security/permissions settings in project properties and enable URL parameters to be passed and try enclosing the code with Try 'write code here Catch ex as Exception End Try

        C T 2 Replies Last reply
        0
        • V Vivek Narayanan

          goto security/permissions settings in project properties and enable URL parameters to be passed and try enclosing the code with Try 'write code here Catch ex as Exception End Try

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          How does catching and ignoring all errors solve the problem ?

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • V Vivek Narayanan

            goto security/permissions settings in project properties and enable URL parameters to be passed and try enclosing the code with Try 'write code here Catch ex as Exception End Try

            T Offline
            T Offline
            tcombs07
            wrote on last edited by
            #5

            Thanks, Here is the error message ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. and that is happening when the service tries to execute the webbrowser1.navigate("url")

            V C 2 Replies Last reply
            0
            • T tcombs07

              Thanks, Here is the error message ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. and that is happening when the service tries to execute the webbrowser1.navigate("url")

              V Offline
              V Offline
              Vivek Narayanan
              wrote on last edited by
              #6

              did you check the permissions?i think the control is corrupt,why dont you use the default .net 2.0 control or the url is not in the proper format , make sure it starts with "http://" -- modified at 1:01 Wednesday 9th May, 2007

              C 1 Reply Last reply
              0
              • T tcombs07

                Thanks, Here is the error message ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. and that is happening when the service tries to execute the webbrowser1.navigate("url")

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                You can set your app to run in STA, it's an attribute you add at the top level of your app. I forget the syntax, but google 'set STA VB.NET' and you're bound to find it.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                T 1 Reply Last reply
                0
                • V Vivek Narayanan

                  did you check the permissions?i think the control is corrupt,why dont you use the default .net 2.0 control or the url is not in the proper format , make sure it starts with "http://" -- modified at 1:01 Wednesday 9th May, 2007

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  STA is actually required by some components, I am pretty sure that none of what you're suggesting will help.

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    You can set your app to run in STA, it's an attribute you add at the top level of your app. I forget the syntax, but google 'set STA VB.NET' and you're bound to find it.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    T Offline
                    T Offline
                    tcombs07
                    wrote on last edited by
                    #9

                    Thanks everyone for all the information, but even with all that there is still nothing. Let me see if I can elaborate on what I am trying to do and maybe you guys have a better way of doing it and it can solve my problem. I just need an application or service to browse to a certain page every five minutes. In my case it will be an asp page. Once the services browses to the page it just needs to close the and the asp page takes it from there and starts producing a grid. For instance when it connects properly the grid will show some green, but say the service gets stopped or the computer or server goes down then the grid will start showing red. I hope that all made sense, if not just let me know and i will try to give some more info. I am just hoping someone can help. Thanks, Travis

                    D S 2 Replies Last reply
                    0
                    • T tcombs07

                      Thanks everyone for all the information, but even with all that there is still nothing. Let me see if I can elaborate on what I am trying to do and maybe you guys have a better way of doing it and it can solve my problem. I just need an application or service to browse to a certain page every five minutes. In my case it will be an asp page. Once the services browses to the page it just needs to close the and the asp page takes it from there and starts producing a grid. For instance when it connects properly the grid will show some green, but say the service gets stopped or the computer or server goes down then the grid will start showing red. I hope that all made sense, if not just let me know and i will try to give some more info. I am just hoping someone can help. Thanks, Travis

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      I could be wrong, but I think the WebBrowser control needs to be on a form with a message pump in order to work. Since a Windows Service doesn't have a message pump, this could be what's causing your problem. THe work around would be to not use a WebControl, but instead rewrite the code to use the HttpWebRequest methods instead.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007

                      1 Reply Last reply
                      0
                      • T tcombs07

                        Thanks everyone for all the information, but even with all that there is still nothing. Let me see if I can elaborate on what I am trying to do and maybe you guys have a better way of doing it and it can solve my problem. I just need an application or service to browse to a certain page every five minutes. In my case it will be an asp page. Once the services browses to the page it just needs to close the and the asp page takes it from there and starts producing a grid. For instance when it connects properly the grid will show some green, but say the service gets stopped or the computer or server goes down then the grid will start showing red. I hope that all made sense, if not just let me know and i will try to give some more info. I am just hoping someone can help. Thanks, Travis

                        S Offline
                        S Offline
                        SimulationofSai
                        wrote on last edited by
                        #11

                        Use the WebRequest class in System.Net. It's all pretty much self explanatory.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups