I'm not sure I understand what exactly are you asking, but I think the problem is that you're always defining the module as HelloWorld.exe
. What you need to do is to make sure the module name matches the file name.
So, if you want to save the assembly as HelloWorld.dll
, then you need to set the module name to HelloWorld.dll
too.