Question

I am working in VS2010 on a .NET 2.0 class library (lets call it class library A) that is part of a solution containing many .NET 2.0 class libraries (B,C..).

Class library A has a reference to B.

An application uses class library A by loading the assembly of A, and adding things from its manifest into the current application domain.

It does this by overriding the AssemblyResolve event (which fires when the assembly cannot be found) and loading the library for B by reading it from the manifest's stream of A.

This works for all of the other class libraries that are referenced like this.

For some reason, class library B (although referenced in the manifest of A) is not embedded in the manifest of A

I have a class lib C that includes a reference to class lib B and successfully loads as described above.

Both class lib A and class lib C have the following:

.assembly extern FluorineFx
{
  .ver 1:0:0:15
}

In the manifest for C there is a .mresource for lib B, which is missing in lib A's manifest:

.mresource public ClassLibB.FluorineFx.dll
{
  // Offset: 0x00000000 Length: 0x000EC000
}

How can I make sure that B is embedded in the manifest of A (preferably from the project's IDE)?

Was it helpful?

Solution

Turns out that there were two differences between the A and C project files:

  1. In C, the item group for the FluorineFx referenced library had an extra piece of XML in it

    <Embed>true</Embed>

  2. In C, a BeforeBuild task was added to the project:

    <Target Name="BeforeBuild"> <CreateItem Include="@(ProjectReference->'%(RootDir)%(Directory)bin\$(Configuration)*.dll')" Condition="%(ProjectReference.Embed)=='True'"> <Output TaskParameter="Include" ItemName="ProjectReferencesToInclude" /> </CreateItem> <Message Text="ProjectReferencesToInclude contains @(ProjectReferencesToInclude)" Importance="High" /> <ItemGroup> <EmbeddedResource Include="@(ProjectReferencesToInclude)"> <LogicalName>ClassLibA.%(Filename).dll</LogicalName> </EmbeddedResource> </ItemGroup> <Message Text="EmbeddedResources now contains @(EmbeddedResource)" Importance="High" /> </Target>

When I made these changes to A, it builds with the FluorineFx embedded included in the manifest. Not only that, it also included libraries that FluorineFx used - antlr, and log4net!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top