2

I have been using VS2015 to generate an interop wrapper for a COM object in the past. The COM object is under ongoing development so sometimes the interface changes and I have to regenerate the interop wrapper. So far no problem. But since I have upgraded to VS2017 I have noticed that the code of the interop wrapper has changed. Making my project not compile.

Specifically the difference seems to be that in VS2015 I would get properties coming through but in VS2017 I get a pair of get_ and set_ methods.

eg I could use something like

string dummy = comObject.AProperty;

if using the VS2015 generated COM wrapper. But it would have to change to

string dummy = comObject.get_AProperty();

instead when using the VS2017 generated COM wrapper.

Decompiling the two wrappers from both versions I can see they are defined like this:

VS2015

[TypeLibType(4176)]
  [Guid("XXXXXXX")]
  [ComImport]
  public interface Iv6ComFrame
  {
  //snip
    [DispId(232)]
    DesignList FaceList { [DispId(232), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] [return: MarshalAs(UnmanagedType.Interface)] get; }
  //snip
  }

In VS2017

  [Guid("XXXXXXXXX")]
  [TypeLibType(TypeLibTypeFlags.FHidden | TypeLibTypeFlags.FDual | TypeLibTypeFlags.FDispatchable)]
  [ComImport]
  public interface Iv6ComFrame
  {
    //snip
    [DispId(228)]
    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
    [return: MarshalAs(UnmanagedType.Interface)]
    DesignList get_FaceList();
    //snip
  }

Is there any way of getting the VS2017 to generate an interop wrapper in the old way?

Thanks

Jero
  • 193
  • 1
  • 1
  • 7
  • You could try older versions of tlbimp until you find the good one: https://stackoverflow.com/questions/2659738/visual-studio-2010-tlbimp-generates-net-4-0-interops-in-2-0-projects/10450789 – Simon Mourier Mar 05 '19 at 08:12

0 Answers0