Click here to Skip to main content
15,888,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is odd:
I have an interface in C#:
C#
[ComVisible(true)]
[Guid("24BDD90E-373B-400F-B374-1350CDB9FE76")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IGURecord
{
  [DispId(1)]
  string Id { get; }
  [DispId(2)]
  double GUValue { get; }
  [DispId(3)]
  double RelativeMigrationTime { get; }
  [DispId(4)]
  string GlycanName { get; }
  [DispId(5)]
  double MonoisotopicMass { get; }
}

In the generated .TLB the GUValue, RelativeMigrationTime and GlycanName properties are getting the leading characters lowercased:
interface IGURecord : IDispatch {
    [id(0x00000001), propget]
    HRESULT Id([out, retval] BSTR* pRetVal);
    [id(0x00000002), propget]
    HRESULT guValue([out, retval] double* pRetVal);
    [id(0x00000003), propget]
    HRESULT relativeMigrationTime([out, retval] double* pRetVal);
    [id(0x00000004), propget]
    HRESULT glycanName([out, retval] BSTR* pRetVal);
    [id(0x00000005), propget]
    HRESULT MonoisotopicMass([out, retval] double* pRetVal);
};

Does anyone have any ideas on why this could be happening?

What I have tried:

There isn't anything unusual I'm doing in this C# assembly.
This is VS 2013.
I've checked the "Register for COM interop" in the project build settings.
There are other interfaces in this assembly defined similarly that aren't seeing this issue.
Posted
Updated 15-Jul-16 12:26pm
v2

1 solution

OK, I'm going to claim this is a bug, although I don't know if it's in Visual Studio, or in REGASM.exe when it creates the Type library:

It seems that somewhere along the process identifiers are not being considered totally unique based on casing. I had methods on the other ComVisible interfaces that had parameters that used the same identifiers that were the problems here, except with the leading lowercase.
I also noticed something else: I had parameters on some methods that were cased the same as different property names.

On a hunch, I renamed all of the method property names so that they didn't match any identifiers with different casing.
That solved the issue.
All of the identifiers in the Type Library now have the same casing as in the defining C# interfaces.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900