1

I'm trying to publish my project as a click once application, everything builds and compiles properly and I can run the program. The issue is that during run time on the click once I keep getting The type initializer for 'Emgu.CV.CvInvoke' threw an exception. When launching the application from Visual Studio in debug or release mode I have no problems. I've determined that this is because the x86 and x64 folders from my nuget package were not being copied into the application files.

My application also doesn't directly reference emgucv. They way it works is that I have my MainProject reference Library A which references Library B which has the nuget package for emgu CV.

They all target Any CPU and run .Net Framework 4.7

I have also added the following post build events to copy unmanaged dlls:

MainProject:

copy "$(SolutionDir)LibraryA\$(OutDir)." "$(TargetDir)" /d

Library A:

copy "$(ProjectDir)Unmanaged*.*" "$(TargetDir)"

copy "$(SolutionDir)LibraryB\$(OutDir)." "$(TargetDir)" /d

When I look at the application files where things get published to I don't see either the x86 or x64 folders that include the cvextern.dll emgu depends on.

I feel as though I'm missing something important that is preventing CvExtern from being copied automatically.

Updating from version 3.1 to 3.4 did not help either.

I have found one solution by copying the folders from the package's folder into the main project and setting them to Copy Always however that feels more like a work around then a solution because I feel as though I shouldn't need to reference the files from multiple projects.

Mark
  • 768
  • 3
  • 8
  • 26
  • Check out this thread: https://stackoverflow.com/a/26712024/229930 The problem appears to be with the way that wrapper works... – Dean Kuga Jun 14 '18 at 22:10

1 Answers1

3

In Visual Studio create new project folders for x86 and x64 in the project that is being published. Copy the Emgu dll(s) from the bin folder into the new solution folders. Include the files in the project as Content and set "Copy to Output Directory" property to "Copy If Newer" for each file. This should result in publisher including the files in the deployment and placing the files in the correct relative path.

Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
  • Looks like all of my .dll files have that, but I did notice that the .dll's (x86/cvextern.dll) that are not publishing are also missing in that list. When I show all files the only things that don't have those settings set by default are pdb and xml files. – Mark Jun 14 '18 at 20:31
  • I had this problem with another nuget library and had to copy it manually to the project as described here. Why does this happen? – Ben Quan Jul 27 '22 at 14:02