
The documentation instructs us to generate assembly cache files indirectly by loading the assemblies into the application project and then retrieving the cache files that should be generated automatically. But this seems to work unreliably - for a lot of assemblies, the cache file is never generated for some reason, although the assemblies themselves load perfectly fine (and their types are resolved properly in the editor). Perhaps this has something to do with optimizations in the file-based cache generator.
The following snippet will create cache files directly, and works 100% reliably for me:
private void GetCache(params string[] paths)
{
var repository = new FileBasedAssemblyRepository(@"C:\temp\Cache");
paths.ToList().ForEach(path =>
{
var assemblyCache = repository.LoadFrom(path);
var serializer = new BinaryAssemblySerializer();
using (var stream = File.Create(String.Format(@"c:\temp\Cache\{0}.Reflection.dat", Path.GetFileName(path))))
{
serializer.SaveToStream(assemblyCache, stream);
}
});
}
Is this approach valid? In that case it might be good to mention this in the documentation. I was completely stuck until I found this.
[Modified 12 years ago]