Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Application: WindowsService1.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception.

Exception Info: System.InvalidOperationException at System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window) at System.Windows.Forms.CommonDialog.ShowDialog() at WcfService1.Service1+<>c__DisplayClass1_0.b__0() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()


What I have tried:

I tried by setting up user as currentuser,still i cannot open filedialog
Posted
Updated 1-Jun-21 4:24am

1 solution

A Windows Service is a non-interactive process which runs in the background. There could be multiple users logged in to the computer, or there might not be any users logged in to the computer. Therefore, a service cannot show any user interface at all.

There used to be an option to allow services to interact with the desktop. However, this was a security issue, and has been disabled in all recent versions of Windows.

Your only option is to have an application running on the user's desktop which subscribes to an event on the WCF service and displays the appropriate UI:
How to: Create a Duplex Contract - WCF | Microsoft Docs[^]
 
Share this answer
 
Comments
Elite Labs 1-Jun-21 11:00am    
Is i need to build two setups one for service and another one for ui
Richard Deeming 1-Jun-21 11:03am    
Yes, you'll need two different applications.
Elite Labs 1-Jun-21 11:04am    
Can u describe how to connect both setups interlinked
Richard Deeming 1-Jun-21 11:08am    
The Microsoft Docs link in my answer explains how to connect the two applications using a duplex WCF contract.
Elite Labs 1-Jun-21 11:20am    
okay,thank's a lot i will give a try and get u back..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900