.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

windows form is not visible in windows service????

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :.NET Framework
i am trying to open an windows form in my windows service OnStart() method but it is not opened can anybody help me my code is: protected override void OnStart(string[] args)         {             // TODO: Add code here to start your service.                         Thread t = new Thread(new ThreadStart(delegate             {                 Form1 f = new Form1();                 Application.Run(f);             }));             t.SetApartmentState(ApartmentState.STA);             t.Start();         }

View Complete Post

More Related Resource Links

SelfHosted WCF Service in a Windows Form Application

Hey,   I have a simple console app that is a self hosted service and a second console app that acts as the client.  I can pass a message between the client and service.  Obviously for this to work the service has to stay up and running, so I put a Console.ReadLine(); command as the last line in the service console app to prevent the service from closing until the user presses enter. My problem is, I would like to (self)host the service in a windows form.  If, for example, I put the ServiceHost decleration in the form load method, the service does not stay open once the form load method is complete. Does anyone have any tips on how I can self host the service in a windows form application and keep the service alive?   Thanks ;o)

Windows Service Applications Tutorials

You can easily create services by creating an application that is installed as a service. For example, suppose you want to monitor performance counter data and react to threshold values. You could write a Windows Service application that listens to the performance counter data, deploy the application, and begin collecting and analyzing data.

Web Service Workflows: Deploy Distributed Business Processes With Windows Workflow And Web Services


Due to the distributed nature of a business process it makes sense for a workflow to be deployed as a distributed application. See how Windows Workflow and Web Services hold the key.

Israel Hilerio

MSDN Magazine October 2006

Service Station: Serialization in Windows Communication Foundation


Windows Communication Foundation supports several serialization mechanisms and provides a simple, interoperable foundation for future service-oriented applications. Here Aaron Skonnard explains it all.

Aaron Skonnard

MSDN Magazine August 2006

Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy


Windows services are applications that run outside of any particular user context in Windows NT, Windows 2000, or Windows XP. The creation of services used to require expert coding skills and generally required C or C++. Visual Studio .NET now makes it easy for you to create a Windows service, whether you're writing code in C++, C#, or Visual Basic. You can also write a Windows service in any other language that targets the common language runtime. This article walks you through the creation of a useful Windows service, then demonstrates how to install, test, and debug the service.

Ken Getz

MSDN Magazine December 2001

Windows authentication login form issue


Hi guys,

I have an application that requires windows authentication to login, the problem is that every time an user logs in under IE and win XP, the username is pre filled with the IP address of the server as instance and the username. I need to replace the server ip with  XXXX instance name instead of doing this manually.

Could anyone pleas help me out with this one?

Thanks in advance,


Open a windows application form names in another

Hi, Now i am in a horrible situation. I want to create an application for open another application(exe) and display all the form names in newly opened application in a compobox.If we selected a compobox item,ie;a form name in new application opened,i want to display all the control names in that form... is it possible? we can do it in same application.but how can i do it in another application? thanks in advance   Anoop

Possible to truly "scale" a Windows Form?

Hi all! I'm trying to think of a way to truly "scale" a Windows Form. I don't just mean resize the form and rearrange the controls accordingly; I mean really "Honey I shrunk the form!" type of shrink, including all text and graphics, as if they had been drawn on a Graphics object with a scale transform less than 1. Aero does this when it shows a shrunken window preview icon... that's exactly what I want, except I want it to happen to the window itself as the user resizes it. I know WPF can do this, but I need a way that'll work on a standard Windows Form without rewriting or massively re-engineering the UI. Any creative ideas? Thanks in advance! :-D

Getting AppDomain.UnhandledException event to work in a Windows Service

Nearly every forum thread I have found on "catching unhandled exceptions in a service" seems to end up where I am.  The supposed solution is the use of the AppDomain.CurrentDomain.UnhandledException event.  But it doesn't work for someone, who then asks why and gets no answer.  Same for me; I can't get the event to happen.  It's as if I need the ServiceProcess version of Application.SetUnhandledExceptionMode(), which doesn't exist. For diagnosing this, I start a timer in a child object of the service and then throw an exception in the timer event handler.  Simple enough to simulate the real situation.  I have tried subscribing to the UnhandledException event in at least a half dozen locations throughout the service, from the Program that runs ServiceBase.Run() to the constructor of the object that owns the Timer, but it never catches this exception. The VS debugger recognizes that the forced exception is unhandled and takes me to the place where is thrown, letting me know it is an unhandled exception. Why doesn't my handler catch it?  Running without the debugger, the exception throws, the timer thread crashes, the service continues merrily along, and nothing gets logged anywhere.  That is NOT the result I need.  What are the people for whom this works doing that I am not doing? How can I at least get the offe

Transfering Data from Windows form application to a website

Hello Friends I have a windows form application and i have to transfer the data from my forms that have been retrieved from SQL server database to a website. So that i can automate the data entry on the website. Can anybody please tell how should i go about doing this. Thanks & Regards, Syed

Windows Identity Foundation Security Token Service can't stay logged in

I'm using the Windows Identity Foundation **(WIF)** Security Token Service **(STS)** to handle authentication for my application which is working all well and good. However I can't seem to get any long running login with the STS. From my understanding I shouldn't care about the client tokens at the application level since they can expire all they want to and it should redirect me to the STS and as long as they're still logged in on the STS it should refresh their application token. Yet it doesn't seem to want to keep them signed in. Here's what occurs in my login.aspx on the STS var cookie = FormsAuthentication.GetAuthCookie(userName, persistTicket); if (persistTicket) cookie.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); var returnUrl = Request.QueryString["ReturnUrl"]; Response.Redirect(returnUrl ?? "default.aspx"); Which was taken almost directly from existing application using normal Forms Auth. From my web.config <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="2880" name=".STS" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /> </auth

Unexplained Crash on .NET Windows Form, Potentially a Common Crash?

Hi, I have a continuous problem with a .NET Framework 3.5 Windows Form application crashing with the "...this application has performed an illegal error..." error message.  No errors are being caught through a Try-Catch (using a generic Exception, so to my knowledge it should catch any exception?) block throughout the application, so it appears to be something external.  At first we thought it may have been the users computer, but even after a replacement computer the same error continues.   I was just wondering if there are any common crashes which have any hotfixes etc. for .NET Framework 3.5? Or if anyone else has experienced anything similar?   Thanks

Cash Drawer - Method Open threw an exception - Windows Service

Hi All, I'm getting the following exception while calling Open method of Cash Drawer object. Method Open threw an exception.  Could not read the device name key's default value, or could not convert the Programmatic ID it holds into a valid Class ID. Code:   class Class1 { CashDrawer _uniCashDrawer1 = null; DeviceInfo cashDrawerDevice1 = null; PosExplorer posExplorer = new Microsoft.PointOfService.PosExplorer();   public void ClaimCashDrawer() { cashDrawerDevice1 = posExplorer.GetDevice("CashDrawer", "testDrawer"); if (cashDrawerDevice1 != null) { _uniCashDrawer1 = posExplorer.CreateInstance(cashDrawerDevice1) as CashDrawer; if (_uniCashDrawer1 != null) { _uniCashDrawer1.StatusUpdateEvent += new StatusUpdateEventHandler(UniCashDrawer1_StatusUpdateEvent); _uniCashDrawer1.Open(); _uniCashDrawer1.Claim(0); _uniCashDrawer1.DeviceEnabled = true; } } } }   Tha above code works fine if you put the code in WindowsApplication in all POS systems. The same is working if you put the code in Windows Service in all other POS systems. The same is not working if you put the code in Windows Service in Aures Galeo POS systems.  Thanks in advance. Ramakrishnan S

how do i create a windows form application login for to validate username and password from sql serv

 I would like to know how I can create a login form for my windows form application. The login form must be linked to a SQL server 2005 express edition database (in which the username and passwords are stored). The login form must validate the user using the database and allow them to access the program. 

How can I debug Windows Service using Visual Studio?

How can I debug Windows Service using Visual Studio? I wrote in Visual Studio 2008 Command Promt: installutil -i c:\projects\MyProject\bin\debug\win.exe I did Start to may service ,but every time that I want to debug service I get: Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.   What am I doing wrong?   Thanks, Raya        

logoff doesn't work through windows service

Dear Friends, I am facing this problem on Windows 2003 and 2008 Server. On XP it works fine. I have written and Windows Service that takes receives the command and executes tasks such as Logoff, Shutdown, etc. All the commands except Logoff works fine. I tried following ways to perform the Logoff. However it didnt work. Try 1:                 Process.Start("shutdown", "-l"); Try 2:     [DllImport("user32.dll")]     public static extern int ExitWindowsEx(int uFlags, int dwReason);     ExitWindowsEx(0, 0); Try 3:     Process _currentProcess = new Process();                _currentProcess.StartInfo = new ProcessStartInfo("shutdown", "-l -f");                _currentProcess.StartInfo.UseShellExecute = false;                 _currentProcess.Start(); Try 4:     Process.Start("logoff.exe", null); If I write a simple C# based applicatin (not Service) it works fine for all the tries that I have made. I am facing this problem only when I put this code

WCF Windows service hosting - not starting

Hi every experts i have WCF Service and a Windows service project for hosting that service when i install the win service with installutil and click start in services it show this message : "Windows could not start the Virtual WCF Service service on Local Computer. Error 5: Access is denied." i have this problem with this sample too : http://rapidshare.com/files/415123228/WCFSample.rar how can i fix this? THX
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend