Hi,

First of all, Roslyn is not the same as .NET 4.5, so it's not really clear
how these assemblies you're talking about are generated.
Second, when you say "serializeable assembly", what exactly do you mean? An
assembly that puts the SerializableAttribute on all types within the
assembly? (This is what Gavin interpreted.) An assembly that you can write
to disk and read back? (Assemblies can already be stored on disk and read
back.)

I'm just trying a guess and assume the latter: you have an assembly file
(DLL file) generated somehow before runtime, and you want to load it, at
runtime, as a collectible assembly. Is that right? Now, the only way to get
collectible assemblies into the .NET runtime is to define them using
Reflection.Emit, so you can't just load them the ordinary way. Instead,
you'd have to analyze the source assembly's contents and rebuild everything
in memory using Reflection.Emit. The only part where Cecil can help you in
this is the analysis part.

Steps:
- At runtime, somebody needs to use code from assembly A.
- Use Cecil to read in assembly A.
- Create a dynamic collectible in-memory assembly with the same full name
as A.
- Use Reflection.Emit to redefine everything found within the real assembly
A in the dynamic assembly.

If this is what you need, this will probably work (although cloning an
assembly in memory will be a very complex task). However, consider the
limitations of collectible assemblies listed here:
http://msdn.microsoft.com/en-us/library/dd554932.aspx.

One interesting thing to research is whether it is possible to return a
collectible assembly from the AppDomain.AssemblyResolve event. If this is
not possible, your code wouldn't be able to statically reference assembly
A; everything would need to be triggered dynamically.

Regards,
Fabian

On Thu, Jun 28, 2012 at 12:13 AM, Dlux <[email protected]> wrote:

> Good day (or night) fine developers.  I am considering using Cecil to
> create an assembly cloner and loader.  This was take assemblies generated
> by Rosalyn (NET 4.5), clone them to a serializeable assembly that I could
> then save, and then later reconstruct a CollectibleAssembly from the
> serialized version.  This would be used on file close in an application
> that uses a great many expressions to convert raw values into unitized
> values.  I'd save the compiled version as a part of the "document", sign
> it, then on load, if the signature vets, I don't have to recompile them.
>
> From looking at Cecil I think I could do this, but I haven't done anything
> this low-level with assemblies before.  Does anyone else have any relevant
> experience or knowledge on roadblocks or problems I may encounter
> [attempting to] do this?
>
> David L-
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to