I would register a extension for the program. You know, when you klick a xls-file, it starts excel with the url to the xls-file as a parameter, and if you klick on a play-list-file it starts your mediaplayer.
You can register an extension for (exemple) ".fro"-files that opens your program with the .fro-file as an parameter.
If your program is allready running, it gets the parameter, or else it starts the program and passes the parameter. Your program reads the file and follow the commands in the file.
So, for example, if you have a link in your web-app that should make your winform-program to open up a customer and show the customer detail, you make your web app have a link <a href="opencustomer.fro">Open customer</a>
, the file opencustomer.fro could be dynamically created or static.
Register the file extension ".fro" to open your .Net program. (example following)
Make web site create .fro-files with commands in them.
Make your .Net program to single-instance application following this tutorial ( http://visualstudiomagazine.com/articles/2007/11/01/simplify-application-instancing.aspx ) . So if a second instance is started, it sends the command$ to the first instance via named pipes.
Make your .Net program download the .fro-file and interpret the command in the file. That could be as simple as just containing a customernumber to open.
I found this vb.net example about register filetypes, it should not be hard to convert or google C#-version of it: http://bytes.com/topic/net/answers/519230-vb-net-associate-file-program
Public Class Example
Public Sub RegisterType()
Dim fileReg As New FileTypeRegistrar
With fileReg
.FullPath = Path_To_Executable
.FileExtension = Extension_To_Register
.ContentType = "application/" & Your_Description
.IconIndex = Icon_Index_In_Application
.IconPath = Path_To_Executable
.ProperName = Name_Of_Executable
.CreateType()
End With
End Sub
End Class
Public Class FileTypeRegistrar
#Region "Properties & Property Variables"
Private _ProperName As String
Public Property ProperName() As String
Get
Return _ProperName
End Get
Set(ByVal Value As String)
_ProperName = Value
End Set
End Property
Private _ContentType As String
Public Property ContentType() As String
Get
Return _ContentType
End Get
Set(ByVal Value As String)
_ContentType = Value
End Set
End Property
Private _FullPath As String
Public Property FullPath() As String
Get
Return _FullPath
End Get
Set(ByVal Value As String)
_FullPath = Value
End Set
End Property
Private _FileExtension As String
Public Property FileExtension() As String
Get
Return _FileExtension
End Get
Set(ByVal Value As String)
_FileExtension = Value.Replace(".", "")
End Set
End Property
Private _IconPath As String
Public Property IconPath() As String
Get
Return _IconPath
End Get
Set(ByVal Value As String)
_IconPath = Value
End Set
End Property
Private _IconIndex As Integer
Public Property IconIndex() As Integer
Get
Return _IconIndex
End Get
Set(ByVal Value As Integer)
_IconIndex = Value
End Set
End Property
#End Region
#Region "Public Methods"
Public Sub CreateType()
Dim fileName As String = Path.GetFileNameWithoutExtension(FullPath)
Dim Ext As String = "." & FileExtension.ToLower
Dim extKey As RegistryKey = Registry.ClassesRoot.CreateSubKey(Ext)
extKey.SetValue("", fileName)
extKey.SetValue("Content Type", ContentType)
extKey.Close()
Dim mainKey As RegistryKey = Registry.ClassesRoot.CreateSubKey(fileName)
Dim defIconKey As RegistryKey = mainKey.CreateSubKey("DefaultIcon")
defIconKey.SetValue("", IconPath & ", " & IconIndex)
defIconKey.Close()
Dim shellKey As RegistryKey = mainKey.CreateSubKey("shell")
Dim OpenKey As RegistryKey = shellKey.CreateSubKey("Open")
Dim cmdKey As RegistryKey = OpenKey.CreateSubKey("command")
cmdKey.SetValue("", """" & FullPath & " %1""")
cmdKey.Close()
OpenKey.Close()
shellKey.Close()
mainKey.Close()
End Sub
Public Sub DeleteType()
Dim fileName As String = Path.GetFileNameWithoutExtension(FullPath)
Dim Ext As String = "." & FileExtension.ToLower
Registry.ClassesRoot.DeleteSubKey(Ext)
Registry.ClassesRoot.DeleteSubKey(fileName)
End Sub
#End Region
End Class