I’m generating an assembly (*.dll) at runtime. the compilation process is performed using CodeDom, as is recommended in following post:
Generating DLL assembly dynamically at run time
My code and assembly are generated successfully, not errors. The problem comes when I’m attempting load this generated assemblies at runtime via reflection using :
// load for reflection only
var _assemblyTempLoad = Assembly.LoadFrom(assembly.FullName);
Following exception is thrown:
“Could not load file or assembly ‘nameforassembly.dll’ or one of its
dependencies. The module was expected to contain an assembly
manifest.”
How to generate the manifest file or fix this issue?
I want clarify that assembly is generated at runtime, using following code:
CompilerResults compilerResult = codeDomProvider.CompileAssemblyFromFile(compilerParameters, Path.Combine(path, sourceCodeFile));`
Thank you in advance
when an assembly is created at runtime (on the fly), the assembly info or metadata is not placed into assembly automatically. The use of the [Assembly] attribute was necessary too. On this way, the last step in the process was place the /platform argument to the compiler (thanks sgmoore). I can saw this using Redgate reflector. The assembly was shown without versioning and metadata attributes. Like this: