The reason this was happening was because of this line:
ModuleBuilder mb = ab.DefineDynamicModule(an.Name, "MainModule");
The DefineDynamicModule has an overload which lets you specify whether symbol information should be emitted, and by default it's false.
By setting this emitSymbolInfo argument to true, it will also emit the pdb file for your assembly.
So I passed in the argument and my problem was solved:
ModuleBuilder mb = ab.DefineDynamicModule(an.Name, "MainModule", true);