Yes, I think I read somewhere that in VS2005, the compiler kept track of
form references automatically. Maybe someone else knows for sure.
In case my memory is faulty, here is an approach that I coded starting in
the VS2003 era and updated in VS2005 to take advantage of the new TryCast
statement in VS2005:
In a module declare a dictionary of weakreferences:
Public Shared dictForm As New Dictionary(Of String, WeakReference)
In the load event of each form in the solution, "register" the form in the
dictionary:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not dictForm.ContainsKey(Me.Name) Then
dictForm.Add(Me.Name, wr)
End If
Then, whenever to want to refer to any other form in the solution:
Dim wr As WeakReference = Nothing
If dictForm.TryGetValue("frmModuleSplash", wr) Then
Dim frmModuleSplash As Security.frmModuleSplash
frmModuleSplash = TryCast(wr.Target, Security.frmModuleSplash)
If frmModuleSplash IsNot Nothing Then
frmModuleSplash.DoSomething()
End If
End If
"Security" is the name of the "other" project. In fact, in my case
"Security" is a different *Solution* that is referenced in the current
solution. If you had two projects in the same solution, I believe it would
work the same.
HTH
Dean Slindee