0

I'm trying to embed a dll into an executable and have set the dll's

  1. Build action to Embedded Resource, and
  2. Copy to output Directory to Do not copy.

It's still copying it. (I even tried publishing it using Clickonce and it does get published.)

Why?

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • Possibly you'd have added it as a assembly reference somewhere – Sriram Sakthivel May 04 '14 at 12:22
  • @SriramSakthivel Yes, I have. But it doesn't build without that. (Note that it does _not_ copy all assemblies that are referenced. Such as the .net assemblies.) – ispiro May 04 '14 at 12:24
  • .Net assemblies will be in "Global Assemby Cache" so it won't be copied there, else it will be copied because you need it in order for your program to work isn't it? – Sriram Sakthivel May 04 '14 at 12:25
  • possible duplicate of [Embedding DLLs in a compiled executable](http://stackoverflow.com/questions/189549/embedding-dlls-in-a-compiled-executable) – Black Frog May 04 '14 at 12:26
  • @SriramSakthivel I extract it later. (See [here](http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx).) – ispiro May 04 '14 at 12:27
  • 1
    @BlackFrog Where is there an answer there to my question? – ispiro May 04 '14 at 12:29
  • Short answer: It will be copied and that's it. Just delete the file and move on. – Sriram Sakthivel May 04 '14 at 12:29
  • Most probably your dll reference has set Copy To Output Directory set to true which causes it showing up in the output folder. Set it to false in the reference properties and you should be fine. – Alois Kraus May 04 '14 at 12:30
  • @AloisKraus There's only a **Copy local** option. When setting to false I get an error: `Assembly '...' must be strong signed in order to be marked as a prerequisite. `. – ispiro May 04 '14 at 12:33
  • @SriramSakthivel See my previous comment. – ispiro May 04 '14 at 12:34
  • As the error tells you: You need to sign your assembly since it is not clear which one should be taken if multiple asemblies in different folders do exist. See http://stackoverflow.com/questions/5133516/why-am-i-getting-assembly-dll-must-be-strong-signed-in-order-to-be-marked-a This issue has nothing directly to do with the copy to output problem but is only deployment issue which is highlighted there. – Alois Kraus May 04 '14 at 12:35
  • @ispiro I just tried. that works fine for me – Sriram Sakthivel May 04 '14 at 12:38
  • @AloisKraus Thanks. I'll have to try that. However - since it works when I deploy and then delete the dll = My application extracts it and it runs fine _without_ being signed - there must be a way to do it without signing. – ispiro May 04 '14 at 12:41
  • @isprio: See the hints in the other answer. You seem to have the same assembly in different version referenced which causes this behavior. Stick to one version and you should be fine. Also do not set Link To a Specific Version in your reference. – Alois Kraus May 04 '14 at 12:43
  • @AloisKraus a) Thanks. You can transform your comments to an answer. They certainly helped. b) About having different versions - I don't exactly understand that - Even deleting the bin and obj folders didn't help and I don't have another reference to that dll anywhere (that I know of). – ispiro May 04 '14 at 12:47
  • @AloisKraus It doesn't solve the issue because I can't publish the application without security settings on. And setting 'specific version' to true doesn't solve that. – ispiro May 04 '14 at 12:52
  • @SriramSakthivel See my previous comment - It doesn't allow publishing without security settings on. – ispiro May 04 '14 at 12:53
  • @AloisKraus Thanks for the link above - I solved it using [Otiel's](http://stackoverflow.com/a/8123074/939213) answer there. – ispiro May 04 '14 at 13:03

2 Answers2

2

The answer turned out to be as mentioned here - Under Application Files - I changed the Publish Status to Exclude.

Community
  • 1
  • 1
ispiro
  • 26,556
  • 38
  • 136
  • 291
0

Try those ways:

  1. Rebuild solution
  2. Clean then build solution
  3. Delete files at bin folder then build again
Weimin Ye
  • 665
  • 4
  • 15