1

I have c++ native dll, lib and headers file. After I reference lib from c++\cli project, it builds successfully, but since c++\cli project - just a wrapper, I reference it in c# project and no native dll appears in c# project output directory after build. How can I fix it? I would not like to use build event to copy dll`s manually.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Shishkin Pavel
  • 351
  • 2
  • 19
  • downvote, along with comments would be much more useful to me – Shishkin Pavel Feb 24 '15 at 17:42
  • I didn't downvote but I suppose you didn't search a lot... Add the native dll to the C# project as a "Content" build action, along with "Copy to output directory" set to true. – Lucas Trzesniewski Feb 24 '15 at 23:13
  • @LucasTrzesniewski using "copy always", as well as using build events works only if i use wrapper in my own projects. If I need to give this library, depending on wrapper, to someone, they must know about adding some dll`s to "Content" or changing build actions. Thus, this idea does not seem attractive to me. – Shishkin Pavel Feb 25 '15 at 06:53
  • You have to document your dependency anyway (plus your dependency to the C++ runtime redistributable), so I don't think this should be a problem. – Lucas Trzesniewski Feb 25 '15 at 08:21

1 Answers1

3

Thus, I have found only two possible solutions:

  • post-build event in wrapper library, that copies native dll to all c# projects that require it
  • add native dll in c# projects directly and set build action to "Copy to output directory" (in accordance with the Lucas response)
Shishkin Pavel
  • 351
  • 2
  • 19
  • 1
    I think this solution is more elegant and portable: https://stackoverflow.com/a/39385582/1236401 – Mugen Mar 27 '18 at 07:33