VB.Net Service Question
-
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
-
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
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 )
-
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
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
-
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
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 )
-
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
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")
-
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")
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
-
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")
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 )
-
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
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 )
-
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 )
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
-
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
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 -
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
Use the WebRequest class in System.Net. It's all pretty much self explanatory.