Task: create an assembly on the fly with the resource file inside.
I try this option:
private class InProcessCompiler { private string sourceCode = @" using System; namespace Bar { public class Test { } } "; public Assembly BuildAssembyWithResources(string resource) { CompilerParameters cp = new CompilerParameters() { GenerateInMemory = false, OutputAssembly = "test.dll", CoreAssemblyFileName = "test.dll", GenerateExecutable = false, CompilerOptions = "/out:C:\\" }; cp.EmbeddedResources.Add(resource); // Hard-code parameters for test. var po = new Dictionary<string, string> { { "CompilerVersion", "v4.0" } }; var p = new CSharpCodeProvider(po); var ass = p.CompileAssemblyFromSource(cp, sourceCode); return ass.CompiledAssembly; //return Assembly.GetExecutingAssembly(); } } But when dealing with the CompiledAssembly property, use the exit: ((System.IO.FileNotFoundException)(ass.CompiledAssembly))._fusionLog
Here is the complete log:
=== Pre-bind state information === LOG: Where-ref bind. Location = D:\...Tests\bin\Debug\test.dll LOG: Appbase = file:///D:/...Tests/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: The same bind was seen before, and was failed with hr = 0x80070002. Tell me what the problem is or what is missing, please.

CodeDomProvider.CompileAssemblyFromSourcemethod returnsCompilerResults, which has theErrorsproperty. Look what's in it. - Pavel MayorovCS2032- Anton Komyshan