0

I am working on a WPF solution, I have a user control in a separate (included) project, this user control references c++ dlls, included by a post script:

xcopy "$(ProjectDir)x64\*.dll"  "$(TargetDir)"  /Y /E /C /F

The issue is that the main project is not finding these dlls when executing.

Message "Unable to load DLL 'libhelper.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

I think I need to distribute the whole content of my Bin folder.

How can I include these additional dlls in the main project?

DanielV
  • 2,076
  • 2
  • 40
  • 61
  • You need your main project to reference that additional dll or have it as a resource that then is being copied to the output folder. – XAMlMAX Sep 18 '19 at 08:34
  • 1
    Your main project (exe) has to know about this C++ library, so when it builds it will copy the dll to the bin folder. Right now your exe doesn't know about that additional library that's why you get that error. Have you tried adding that dll as a resource to your main project? – XAMlMAX Sep 18 '19 at 08:42
  • I was trying to do it in a way that this is dynamic and so 'hardcoded' like – DanielV Sep 18 '19 at 08:46
  • Not the downvoter, but what you need to do is to add that dll like a resource to your main project. Right click your project->Add Exising Item->(find your C++ dll). Then select that dll in your solution explorer, go to Proerties window and set the Build action to `Resource` and set "Copy to Output Directory" to "Copy Always" or "Copy If Newer". This should copy that dll everytime you build. – XAMlMAX Sep 18 '19 at 08:58

1 Answers1

1

You can set the output of your main project and the user control to the same folder. Right click on each of them, then select Build, Output, Output path, set the same directory and save. All the output will go to the same directory therefore you will access all resources.

enter image description here

Juanito
  • 420
  • 1
  • 4
  • 18