Connecting Tech Pros Worldwide Forums | Help | Site Map

CodeDom - Namespace/Class interaction between Ns1 and CodeDom's Ns2

Newbie
 
Join Date: Oct 2008
Posts: 9
#1: Oct 22 '08
Hello,

I was wondering if anyone might know the easiest way to access static methods through a namespace(MyNamespace) from CodeDom generated code?



Basically I have this in my MyNamespace.Form:

//////// Most of this below is almost useless jargon just to give an idea of what values are set or not
public CodeDom.Compiler.CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider();

public System.CodeDom.Compiler.CompilerParameters parms = new System.CodeDom.Compiler.CompilerParameters();
parms.GenerateExecutable = false;
parms.GenerateInMemory = true;
parms.ReferencedAssemblies.Add("System.dll");

public CodeCompileUnit compileUnit = new CodeCompileUnit();

public CodeNamespace namespacee = new CodeNamespace("CodeDomNamespace");


namespacee.Imports.Add(new CodeNamespaceImport("System"));
namespacee.Imports.Add(new CodeNamespaceImport("MyNamespace"));

///End jargon above, my question below:

Currently in code:

public string code = @"pubilc static string StringTest()
{
return ""the test""
}
";

but I'd like the code string to say this:

public string code = @"public static string StringTest()
{
return MyNamespace.MyClass.MyRoutine("test");
}


And in MyRoutine...

public static string MyRoutine(string s)
{
s = s + "1";
return s;
}


However when I try this, I keep getting an error in my reflection setup:

Could not load file or assembly 'file:///C:\Users\rolo\Appdata\Local\Temp\przvq1_b.dll' or one of its dependencies. The system cannot find the file specified.


I'm pretty new at this, it works fine as long as I don't try modify the string code to use "return MyNamespace.MyClass.MyRoutine("test"); " .

Any ideas on how to do this?

Reply


Similar .NET Framework bytes