By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

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

P: 9
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?
Oct 22 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.