How does this work? It's very simple:

public void VerifyAssemblyViaFileInfo()
	AssemblyCreator.Create("", "/dll");
	AssemblyVerification.Verify(new FileInfo("GoodAssembly.dll"));

The idea is you provide an assembly as a file to Verify(), and if you don't get an exception, that assembly is verified. You need to have peverify accessible from the command-line so when Verify() tries to launch that executable it won't fail. If it can't find peverify, it'll choke :).

If you create a lot of dynamic code, this technique makes it very easy to quickly ensure your generated code doesn't contain any bad IL-related mistakes.

Last edited Feb 13, 2011 at 11:29 PM by jasonrbock, version 1


No comments yet.