1
votes

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.

1
downvote, along with comments would be much more useful to meShishkin Pavel
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
@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
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

1 Answers

3
votes

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)