How to make COMReference work in Azure CI/CD pipeline
Asked Answered
C

1

4

I have used a dll to my project which gets added to my project file as a COMReference like following

<COMReference Include="GENERALCREDITREQUESTMANAGER450Lib">
  <Guid>{BDB6DDB5-5C02-492F-954E-68ED3D8F075D}</Guid>
  <VersionMajor>1</VersionMajor>
  <VersionMinor>0</VersionMinor>
  <Lcid>0</Lcid>
  <WrapperTool>tlbimp</WrapperTool>
  <Isolated>False</Isolated>
  <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>

Now the problem is it fails during my pipeline build, saying Namespace or type GENERALCREDITREQUESTMANAGER450Lib can't be found which is understandable because unlike other references it doesn't have any HintPath to locate the dll.

After looking around a bit I found this article that basically says use tlbImp to generate the dll and then reference that dll using the following syntax:

<Reference Include="GENERALCREDITREQUESTMANAGER450Lib">
  <HintPath>InteropAssemblies\GENERALCREDITREQUESTMANAGER450Lib.dll</HintPath>
  <EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>

But if I do that then my visual studio build fails, because then VS can't find the namespace even though it's added to the reference. One of the post suggested to use COMFileReference instead of COMReference but that ends up with same "Namespace not found" error.

How can I make the pipleline working?

Curie answered 13/4, 2021 at 8:32 Comment(2)
when you used tlbImp manually, did you use its /namspace:GENERALCREDITREQUESTMANAGER450Lib option? - ReferenceKathrinekathryn
@MartinUllrich: That was it! Thanks a lot! If you post that as answer I will accept that as answer.Curie
K
2

The COMReference item requires the library to registered on the build server which may be hard to do depending on the environment.

The way to use tlbimp locally and add the generated .dll to the project sources is likely more compatible for your setup though it requires you to pass the namespace as a parameter (/namspace:GENERALCREDITREQUESTMANAGER450Lib) to achieve the same result as the COMReference.

Kathrinekathryn answered 13/4, 2021 at 13:42 Comment(1)
Note for future users. ComFileReference also works after using /namespaceCurie

© 2022 - 2024 — McMap. All rights reserved.