1

I have an app that references a .dll that was built with Costura/Fody i.e The dll has all its references embedded. When I run the console app, the references from the dll are not unpacked so the console app throws an exception saying missing .dll etc. as it needs those resources to run. i.e. AssemblyA.dll embeds MyAssembly.dll when built with Costura/Fody. ConsoleAppC references and embeds AssemblyA.dll but also needs MyAssembly.dll to run. I do have a reference to MyAssembly.dll in ConsoleAppC so that it will compile (but CopyLocal is set to false). I was thinking that MyAssembly.dll would be made available to ConsoleAppC when AssemblyA.dll's embedded resources are unpacked?

This is not working but is my scenario valid in any way or can you only utilise embedded resources from ConsoleAppC and not the ones that were embedded in AssemblyA.dll?

Thanks in advance for any help

Mike

mikip
  • 21
  • 3
  • Possible duplicate of [Costura.Fody Embedded Library Namespaces Not Found](https://stackoverflow.com/questions/44658126/costura-fody-embedded-library-namespaces-not-found) – Eliza Bennet Oct 02 '18 at 17:47

1 Answers1

1

What you're trying to do isn't possible with Costura.Fody. What Costura does is embed libraries directly into the main assembly. This means that if you embed the built assembly into another project, it can't see the sub assemblies.

For example, consider the following project structure:

AssemblyA
    Foo.cs
    References:
    SubAssembly1.dll
    SubAssembly2.dll
    SubAssembly3.dll
AssemblyB

Assume that Costura.Fody is used to embed the sub assemblies in AssemblyA, creating a single DLL file, AssemblyA.dll

If you embed AssemblyA.dll in AssemblyB, then you will not be able to access classes in SubAssembly1.dll. You will only be able to see any of the classes that are directly in AssemblyA.dll, such as those contained in Foo.cs - you will not be able to see any of the libraries referenced by/embedded in AssemblyA.dll.

See this answer to a similar question, where the answerer suggests using ILMerge instead.

Eliza Bennet
  • 179
  • 4
  • 17