Using CodeDom to generate a CF assembly...

A

Antao Almada

I'm trying to use CodeDom to dinamically generate an assembly to be used
on a PDA.

After setting all the dependencies for a CF assembly, I can see in the
Lutz Roeder's Reflector that, my assembly depends on both the CF
mscorlib.dll and the non-CF mscorlib.dll.

I run a small test (source at the end of this post) with a single class
source and, once more, the resulting assembly depends on the non-CF
mscorlib.dll.

Is the CodeDom wrongly assuming that all assemblies will depend on the
non-CF mscorlib.dll? Am I doing something wrong?

Thanks,
Antao
____________________________
Antao Almada
http://www.ydreams.com/

CSharpCodeProvider compiler = new CSharpCodeProvider();
ICodeCompiler codeCompiler = compiler.CreateCompiler();

string code = @"
using System;

namespace Test
{
public class Class1
{
public Class1()
{
}
}
}
";

CompilerParameters compilerParams = new CompilerParameters();

compilerParams.CompilerOptions += " /filealign:4096"; // for better PE
file aligment

// find the location of System.dll for the Compact Framework
RegistryKey registryKey = Registry.LocalMachine;
registryKey =
registryKey.OpenSubKey(@"SOFTWARE\Microsoft\.NETCompactFramework\");
string systemLocation = (string)registryKey.GetValue("sdkInstallRoot");
systemLocation = Path.Combine(systemLocation, @"v1.0.5000\Windows
CE\System.dll");

compilerParams.ReferencedAssemblies.Add(systemLocation);

compilerParams.OutputAssembly = "Test.dll";
compilerParams.GenerateInMemory = false;
compilerParams.GenerateExecutable = false; // generate a DLL

compilerParams.IncludeDebugInformation = true;

CompilerResults results =
codeCompiler.CompileAssemblyFromSource(compilerParams, code);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top