Before writing this I went through more than 10 questions on this topic to make sure I'm not missing smth obvious, but I couldn't find answers to this specific scenario.
I am working on an enterprise product which has (very unfortunately) inherited some old VB6 code that is still used in several parts of the system. I am currently in the middle of an analysis on how best to identify how much of this VB6 code is actually in use so the company can target strategic migration to .NET. I've come up with the following idea:
In the places where the VB6 code is used the typical code that calls it (VB.NET) looks like:
Dim myComObject = Server.CreateObject("MyCOMObject")
With myComObject
.MyCOMProperty = ""
.MyCOMMethod()
End with
My idea is to build a facade in .NET behind which to hide all the code that calls COM and call the facade abstraction in all the places where the COM code is currently called. In other words:
public interface ICOMFacade
{
public object CreateCOMObject(string comObject)
}
...
Dim myComObject = comFacade.CreateCOMObject("MyCOMObject")
With myComObject
.MyCOMProperty = ""
.MyCOMMethod()
End with
The implementation of CreateCOMObject would internally call Server.CreateObject(comObject) but it would also log this call to a database. In this way I could analyse all the calls to all the COM objects and understand what is used and what isn't. However, this isn't enough. I also need to understand which methods and properties are called from the COM objects. For this reason I need to understand if there is a way in which every method call and property of the COM object can be intercepted.
Thank you.