CSharpCodeProvider add reference, metadata file can not be found
Here is the code:
CodeDomProvider provider =
CSharpCodeProvider.CreateProvider("C#");
CompilerParameters options = new CompilerParameters();
options.ReferencedAssemblies.Add("system.dll");
options.ReferencedAssemblies.Add("system.drawing.dll");
// uncommenting this will cause an error
// options.ReferencedAssemblies.Add("PresentationFramework.dll");
options.GenerateExecutable = false;
options.GenerateInMemory = true;
// ...
CompilerResults compile =
provider.CompileAssemblyFromSource(options, source);
How to reference PresentationFramework.dll so I can start using
Microsoft.Win32 namespace in the generated code?
I assume same can occurs with any other assembly, that's why question
title is more generic.
As you can see referencing system.dll or system.drawing.dll is not a
problem. PresentationFramework.dll located in same folder, so
CSharpCodeProvider should be able to find it. Still it throws error. Why?
No comments:
Post a Comment