Saving an Assembly as a byte array suitable for Assembly.Load
I notice that Assembly.LoadFrom has the following overload
public static Assembly Load(
byte[] rawAssembly
)
How d开发者_开发百科o I save an assembly as a byte array in order to create it like this?
Context : I want to write a test harness that will ensure backward compatability of a service. I want to load canned versions of the client into my harness and call the service from many different versions. I think saving the old versions as byte[] would allow me to freeze them.
If you have old versions as files (just as they were normally built) that's all you need. You can read those into a byte array (e.g. with File.ReadAllBytes
) if you need to.
It sounds like you just need to keep the old binaries in source control.
Like so:
byte[] assemblyBytes = File.ReadAllByes(assemblyPath);
NOTE that you will have to load dependent assemblies first.
精彩评论