What causes PIA API to differ between Release and Debug build?

107 Views Asked by At

I have an ocx from a third party from which a Primary Interop Assembly (PIA) is created when I add a control to my form. The PIA exposes an ActiveX API to my .NET Assembly.

The strange thing I have found is that when my solution is set to Debug, some functions are missing compared to when my solution is set to Release. The metadata of the PIAs in the Debug and Release folders differ

Release:

#Region "Assembly AxInterop.DATARAYOCXLib, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
' C:\Users\...\Instruments\obj\x86\Release\AxInterop.DATARAYOCXLib.dll
#End Region

Imports System
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Namespace AxDATARAYOCXLib
    <AxHost.Clsid("{43555bb9-3fe0-11d6-9f4a-00a0cc40a4d2}")> <DefaultEvent("SendMessage")> <DesignTimeVisible(True)>
    Public Class AxGetData
        Inherits AxHost

    Public Overridable Function IsDataReady(index As Short) As Boolean

Debug:

#Region "Assembly AxInterop.DATARAYOCXLib, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
' C:\Users\...\Instruments\obj\Debug\AxInterop.DATARAYOCXLib.dll
#End Region

Imports System
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Namespace AxDATARAYOCXLib
    <AxHost.Clsid("{43555bb9-3fe0-11d6-9f4a-00a0cc40a4d2}")> <DefaultEvent("SendMessage")> <DesignTimeVisible(True)>
    Public Class AxGetData
        Inherits AxHost

    ' IsDataReady is missing

How can the different configurations target different APIs? I have recently updated the third party software to the latest version (which does not include IsDataReady) and have deleted the dlls in both debug and release folders, and rebuilt. The dlls come back, but Release still sees IsDataReady. What is a good way to solve this?

I have tried this...

  • Set solution to Release
  • Removed references to PIA (AxInterop.DATARAYOCXLib.dll and Interop.DATARAYOCXLib.dll)
  • Opened a form and added controls to the Toolbox found in the ocx in Program Files. This action creates the PIA (AFAIK) and adds references.
  • Deleted bin and obj folders
  • Build
  • Check the API. IsDataReady is there

Then I repeated all the steps after setting solution to Debug instead. IsDataReady is not there.

I contacted the vendor and they said this function is deprecated and is not included in the latest ocx. However I definitely see it when building in Release.

1

There are 1 best solutions below

0
On

I used Windows Search to delete every bin and obj directory in my entire solution directory, and rebuilt. Some manual building for some lower level dependent projects was necessary. This solved the problem. Now my Debug and Release builds both show the correct API.

I had tried deleting those directories for just the offending project and its immediate dependencies, but this was not enough by itself.

I am still not sure why this was necessary, or why the project would not overwrite the interop assembly from the latest ocx, even when it was the only version registered on the PC. I hope I don't need to do this every time I get a new version of the ocx, but I'll keep it in mind.