I created a C# .NET 6 COM interop DLL (registered by installer using REGSVR32) for a client of our application’s gRPC remoting interface that worked great in our previous releases of the product.
For our new software release, I need to add more methods to extend the interface. However, when I add the additional methods, it appears that the interface methods are getting mixed up, resulting in COM marshalling exceptions in gRPC. I’ve tried to debug the client COM object, but haven’t been successful getting it to debug it by attaching to the process.
Here is the original Interface definition:
[ComVisible(true)]
[Guid("9DAF4501-4AF6-43FF-95EF-C421CB43F1B8")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[System.Reflection.Obfuscation(Feature = "renaming", Exclude = true, ApplyToMembers = true)]
public interface IWinCalClient5
{
[DispId(1501)]
bool ViewerOpen();
[DispId(1502)]
bool ViewerMeasurement(bool IsCorrected, ref int[] PortList, string DataSetName, bool ReplaceExisting);
[DispId(1503)]
bool ViewerMeasurementStr(bool IsCorrected, string PortList, string DataSetName, bool ReplaceExisting);
[DispId(1504)]
bool ViewerMeasureAllPortsRaw(string DataSetName);
[DispId(1505)]
bool ViewerMeasureCorrected(string DataSetName);
[DispId(1506)]
bool ViewerLoadReport(string FullFileName);
[DispId(1507)]
bool ViewerListNames(out string[] DataItemNames);
[DispId(1508)]
bool ViewerGetDataItem(string DataItemName);
[DispId(1509)]
bool ViewerClose();
[DispId(1510)]
bool ViewerSave();
[DispId(1511)]
bool ViewerSaveAs(string NewReportName);
[DispId(1512)]
bool ViewerLoadData(string NewDataName);
[DispId(1513)]
bool ViewerSaveData(string FileName, bool Overwrite, int ComplexFormat);
[DispId(1514)]
bool ViewerGetStringDataItemValue(string DataItemName, out string Value);
[DispId(1515)]
bool ViewerGetIntDataItemValue(string DataItemName, out int Value);
[DispId(1516)]
bool ViewerGetBoolDataItemValue(string DataItemName, out bool Value);
[DispId(1517)]
bool ViewerGetRealDataItemValue(string DataItemName, out double Value);
[DispId(1518)]
bool ViewerSetStringDataItemValue(string DataItemName, string Value);
[DispId(1519)]
bool ViewerSetIntDataItemValue(string DataItemName, int Value);
[DispId(1520)]
bool ViewerSetBoolDataItemValue(string DataItemName, bool Value);
[DispId(1521)]
bool ViewerSetRealDataItemValue(string DataItemName, double Value);
[DispId(1522)]
bool ViewerGetComplexDataItemValue(string DataItemName, out double RealValue, out double ImaginaryValue);
[DispId(1523)]
bool ViewerSetComplexDataItemValue(string DataItemName, double RealValue, double ImaginaryValue);
}
Here is the NEW Interface definition with the 3 new methods:
[ComVisible(true)]
[Guid("9DAF4501-4AF6-43FF-95EF-C421CB43F1B8")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[System.Reflection.Obfuscation(Feature = "renaming", Exclude = true, ApplyToMembers = true)]
public interface IWinCalClient5
{
[DispId(1501)]
bool ViewerOpen();
[DispId(1502)]
bool ViewerMeasurement(bool IsCorrected, ref int[] PortList, string DataSetName, bool ReplaceExisting);
[DispId(1503)]
bool ViewerMeasurementStr(bool IsCorrected, string PortList, string DataSetName, bool ReplaceExisting);
[DispId(1504)]
bool ViewerMeasureAllPortsRaw(string DataSetName);
[DispId(1505)]
bool ViewerMeasureCorrected(string DataSetName);
[DispId(1506)]
bool ViewerLoadReport(string FullFileName);
[DispId(1507)]
bool ViewerListNames(out string[] DataItemNames);
[DispId(1508)]
bool ViewerGetDataItem(string DataItemName);
[DispId(1509)]
bool ViewerClose();
[DispId(1510)]
bool ViewerSave();
[DispId(1511)]
bool ViewerSaveAs(string NewReportName);
[DispId(1512)]
bool ViewerLoadData(string NewDataName);
[DispId(1513)]
bool ViewerSaveData(string FileName, bool Overwrite, int ComplexFormat);
[DispId(1514)]
bool ViewerGetStringDataItemValue(string DataItemName, out string Value);
[DispId(1515)]
bool ViewerGetIntDataItemValue(string DataItemName, out int Value);
[DispId(1516)]
bool ViewerGetBoolDataItemValue(string DataItemName, out bool Value);
[DispId(1517)]
bool ViewerGetRealDataItemValue(string DataItemName, out double Value);
[DispId(1518)]
bool ViewerSetStringDataItemValue(string DataItemName, string Value);
[DispId(1519)]
bool ViewerSetIntDataItemValue(string DataItemName, int Value);
[DispId(1520)]
bool ViewerSetBoolDataItemValue(string DataItemName, bool Value);
[DispId(1521)]
bool ViewerSetRealDataItemValue(string DataItemName, double Value);
[DispId(1522)]
bool ViewerGetComplexDataItemValue(string DataItemName, out double RealValue, out double ImaginaryValue);
[DispId(1523)]
bool ViewerSetComplexDataItemValue(string DataItemName, double RealValue, double ImaginaryValue);
[DispId(1524)]
bool ViewerSetOnDemandPostProcessing(bool OnDemandPostProcessing);
[DispId(1525)]
bool ViewerGetOnDemandPostProcessing(out bool IsEnabled);
[DispId(1526)]
bool ViewerPerformPostProcessing();
}
I’m fairly certain that the issue is in the client .NET COM server because I noticed the issues, so backed out ONLY the COM interface additions and the client-server functionality worked fine.