1

I have a legacy project that uses a OCX. I had to register said OCX on my system using regsvr32.

Now, I want for Jenkins to compile the project. Unfortunately, in the Jenkins Server there is no OCX and I don't want to register it.

Is there a way to distribute the OCX so the project can compile on Jenkins? I read about registration-free components, but there seems to target runtime requeriments, and my issues are at compile time.

Fernando
  • 2,131
  • 3
  • 27
  • 46
  • Probably you can generate primary interop assembly using [tlbimp.exe](https://learn.microsoft.com/en-us/dotnet/framework/interop/how-to-generate-primary-interop-assemblies-using-tlbimp-exe) and update references to use the assembly. Take a look at [this post](https://stackoverflow.com/q/10700607/3110834) or [this one](https://stackoverflow.com/q/7498258/3110834). – Reza Aghaei Sep 16 '17 at 01:49
  • Jenkins sometimes strikes me as a virus released by the Java community, aimed at making a C# programmer's life as hard as possible. You need to run Aximp.exe so you get both the interop library and the AxHost wrapper that your form uses. Check the two DLLs into source control. Remove the two references from your project and add them back, now using the files. Double-check by verifying that the .csproj no longer contains the two `COMReference` elements. You'd better check the installer or ocx into source control as well the minimize versioning misery this causes. – Hans Passant Sep 16 '17 at 09:48

1 Answers1

1

Yes - the way to do it is as Reza Aghaei says.

Call tlbimp to generate an interop assembly (it doesn't have to be a primary interop assembly). Then instead of referencing the ocx in the project, you reference the interop dll.

Note that if you want to run the project or use the control in the winforms designer you'll still need to register the ocx. Build for Building from Jenkins, this will work fine we use this technique to build our legacy code.

Richard Matheson
  • 1,125
  • 10
  • 24