Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,
I have again a problem.
I'm created a Windows Form program. I'm using WCF.
Host -> console application
Client -> windows form

when i close Client, on Windows Task Manager in the Processes tab it still running(ClientForm). When i click 'End process' it don't shut down, it dos only if I click End process tree!
All should be ok, but when I open Client form again (In Win. Task Manager it takes Name ClientForm(1)), and it takes some arguments from ClientForm.

how I can fix this problem?

Thanks, again! :)
please stay with this post, I will review in morning in Latvia now is 2:45 at night! :)
Posted

How are you closing your form? As you seem to be instantiating the form from the console app it may still retain reference to your form.
Perhaps a code snippet would be useful.
 
Share this answer
 
Hi Valza,

could it be that you started some thread that was not a backgound thread. Threads that are not background threads keep an application from exiting. Can you check that?

Cheers

Manfred
 
Share this answer
 
v2
You probably will still need to show a snippet of your Host (console app) if you are using a console app to spawn the form.
Based on the code you have posted I'd check the following:

1. Make sure when you call this.Close() the "this" reference is referring to ClientForm. Try putting breakpoints and see what happens when you debug this when closing the form.

2. As you called this.Hide() which hides the ClientForm and shows TestuForm it is possible when you closed the application you only closed TestuForm but not ClientForm. Did you attach an event to TestuForm's Form.Closed to also close ClientForm?
In short, make sure the "this.Close()" is called when you close your app from the user interface.

The app.config is most likely just a warning and shouldn't affect your form closing issue.
 
Share this answer
 
When u closing the form,
Add this code,
End 'For VB
 
Share this answer
 
some thred is still running , so close ur application when all threds completes their process ,and u have to also free the memory that the threads are using .
 
Share this answer
 
HI, Edbert P & ManfrerRbihy.

ClientForm is Main form.
TestuForm is subForm.

I'm using WCf.
IService1 channel = null;
       NetTcpBinding bining = new NetTcpBinding();


&

C#
private void ClientForm_Load(object sender, EventArgs e)
       {
           try
           {
               bining.Security.Mode = SecurityMode.None;
               var endPoint = new EndpointAddress("net.tcp://localhost:8080/Service1");
               channel = ChannelFactory<IService1>.CreateChannel(bining, endPoint);
               lblBinding.Text = string.Format("IP: {0}", endPoint.Uri.Authority);
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message);


when I exit ClientForm I use:
C#
private void izietToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }


ON button:
SQL
testID = new TestuForm();
           testID.SelectedTestID = _selectedTestID;
           testID.SelectedSkolenuID = _selectedSkolenuID;
           testID.SelectedSkolotajuID = _selectedSkolotajuID;
           testID.Show();
           this.Hide();


I pass some variables to TestuForm() & hide ClientForm.
on TestForm i use same channel,binding

C#
IService1 channel = null;
NetTcpBinding bining = new NetTcpBinding();



C#
private void TestuForm_Load(object sender, EventArgs e)
        {
            bining.Security.Mode = SecurityMode.None;
            var endPoint = new EndpointAddress("net.tcp://localhost:8080/Service1");
            channel = ChannelFactory<IService1>.CreateChannel(bining, endPoint);
        }


I have tried only open and close ClientForn but still have the problem.
the sutpid process name is WindowsClient.vshost.exe
Description vshost.exe

a few minutes ago I runed the program -> closed.
some times process closes, sometimes not.
Sometimes I just click End Process Tree it closes.
Sometimes I need to try close multiple times before it closes.

this program is my first project I'm playing with C# only about 2 months.
So bee nice. :)
thanks.
 
Share this answer
 
Comments
Toli Cuturicu 25-Nov-10 11:40am    
Don't try to fool us. We can easily spot a fake answer like this one!
Next time I will delete your fake answer.
valza 25-Nov-10 14:53pm    
sorry!
next time i will comment not post Answer. My fault sorry!!!!!!!!!
Edbert P 25-Nov-10 19:16pm    
@Toli: Valza is the poster and he was posting snippets of his code, not trying to answer his own question.
I just noticed that in my app.config file is sometinh like this
XML
<transport clientCredentialType="Windows" proxyCredentialType="None"
                           realm="">
                           <extendedProtectionPolicy policyEnforcement="Never" />
                       </transport>


extendedProtectionPolicy is underlined by a blue wavy line
and it says:
The element 'transport'cannot contain child element 'extendedProtectionPolicy' because the parent element's content model is empty.

maybe this is the problem?
 
Share this answer
 

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