views:

529

answers:

1

I have a Windows Forms application that runs locally on the user's desktop. The only way it accesses the Internet is by doing System.Diagnostics.Process.Start(url) to launch the user's default browser and point it to various URLs (to check for updates, contact us, etc.). And none of this happens without the user explicitly requesting it by clicking a menu item or button.

On my machine I have been occasionally getting a Windows Firewall warning message upon starting up the program, saying that Windows Firewall has "blocked some features" of the program to protect the machine. I also occasionally get this warning when running my program within Visual Studio (and the warning dialog says that vshost has been blocked from the network). It doesn't happen all the time.

I have not heard from any of my customers that this has been happening on their PCs, but that doesn't mean it's not. And it's a somewhat scary warning to a less-technically savvy user, so I'd like to figure out how to eliminate it if possible.

What could my program possibly be doing to trigger this warning?

Edit: The only somewhat unusual thing my program is doing at startup is that it uses the Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase class to enforce a single instance application. I know this does some threading magic behind the scenes to detect new instances and redirect them. Is it possible it's listening on the network for some reason?

+2  A: 

Windows Firewall will only be triggered if your program is listening on a port - effectively acting as a server. System.Diagnostics.Process.Start will not trigger Windows Firewall.

Instead, WindowsFormsApplicationBase is likely causing the firewall warning, because WindowsFormsApplicationBase uses remoting to sense other instances of itself. Using reflector, I found this code in WindowsFormsApplicationBase.Run():

TcpChannel channel = this.RegisterChannel(secureChannel);
RemoteCommunicator communicator = new RemoteCommunicator(this, this.m_MessageRecievedSemaphore);
string uRI = applicationInstanceID + ".rem";
new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Assert();
RemotingServices.Marshal(communicator, uRI);
CodeAccessPermission.RevertAssert();
string uRL = channel.GetUrlsForUri(uRI)[0];
this.WriteUrlToMemoryMappedFile(uRL);
this.m_FirstInstanceSemaphore.Set();
this.DoApplicationModel();

As long as you use WindowsFormsApplicationBase for its SingleInstance feature, I don't know of any way around this.

Greg
That's the thing - there's nothing that is obviously listening on any ports. The warning occurs both within Visual Studio and when I run the installed executable.
Jesse Smith
The one thing that is a little unusual is that I use the Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase to enforce a single instance application. This does threading stuff behind the scenes; I wonder if it could be listening on the network for remote process stuff.
Jesse Smith
Open the command prompt and run "netstat -b" while the program is running to see if it's listening on any ports.
Greg