Search code examples
c#xsdembedded-resource

Embedded resource with al.exe seems to be in there, but won't come out again


I have a project (.net 2 framework for various reasons) where we are generating the schemas off the objects using xsd.exe. We want to embed these schemas into the assembly to use when validating files that are loaded. The xsd file gets generated successfully. I then run al.exe to turn the xsd into an assembly, third stage is that I use ilmerge to merge this assembly into my main assembly so it is available as a resource. I have other resources in there that I have embedded using the using vs way of setting the content type to embeddedResource, I can see those resources in code via a call to GetType().Assembly.GetManifestResourceNames(); I can see the resource that I am after in the manifest of the assembly and it all looks pretty good (not a path name or case issue as far as I can tell). I have looked into the asssembly using ILSpy and ildasm and it all looks ok?

.mresource public MySetup.EmbeddedResources.Mapping.xml      << vs2010 embedded resource
{
 // Offset: 0x00000000 Length: 0x00000C67
}
.mresource public MySetup.EmbeddedResources.Schemas.xsd      << my resource
{
  // Offset: 0x00000C6B Length: 0x00000B47
}

I have tried various options, the same file embeds ok when using vs to embed it and no obvious differences in the manifest either way.

Any idea why GetType().Assembly.GetManifestResourceNames(); is not returning my resource?


Edit: Oops, turns out this was the result of serious brain freeze. It was actually working, but because my Unit tests dll was referencing the old assembly, it wasn't picking up the merged resources..... Dooh!


Solution

  • Oops, turns out this was the result of serious brain freeze. It was actually working, but because my Unit tests dll was referencing the old assembly, it wasn't picking up the merged resource