开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜