Interpretation with COM
.NET clients access a COM server by means of a runtime callable wrapper (RCW). The RCW wraps the COM object and allows it to be used by the CLR environment, making the COM object function just like a .NET object. The code in order to utilize a RCW can be seen below.
Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs)
Dim RuntimeCallableWrapper As New ComUsedByDotNet.Class1()
Label1.Text = RuntimeCallableWrapper.GetTimeFromCom(CheckBox1.Checked)
End Sub
COM objects are actually destroyed when the garbage collects their RCW’s. On the other hand, if you would like to remove one portion of the COM object without affecting others, the function System.Runtime.InteropServices.Marshal.ReleaseComObject will allow the user to utilize the RCW until the garbage collector is called.
Moving the other way, .NET objects can be used in COM as well. The COM client can access a .NET object using a COM callable wrapper (CCW). To operate a CCW, the .NET component’s assembly must be signed with a strong name. If not, the CLR will not be able to identify it. In order for a COM client to find the .NET object, the registry entries in the RegAsm.exe utility program with .NET SDK must be used.