CodeGen can be pretty painful and I find in most cases - especially in script scenarios - it's better to deal with code as strings. CodeGen makes more sense if you're worried about language agnostic compilation (like tools that need to work inside of VS for example) but otherwise I find it's not really worth the hassle. It's just so much easier to generate code and compile that than trying to figure out the appropriate CodeGen syntax.
+++ rick ---
Well - that happens sometimes, you look for days for the answer and 10minutes after you pose the question you find it yourself. I'll post the solution to this forum so other may find it if they need it.
Unlike many tell use in the various forums it IS POSSIBLE to generate the PARAMS-keyword using CodeDOM. I found the answer at this URL
(http://blogs.msdn.com/bclteam/archive/2006/04/10/571096.aspx) in the entry (Wednesday, April 12, 2006 3:50 PM by Benet Devereux).
Copy of his entry:
<SNIP>
C#'s params keyword is syntactic sugar for the ParamArray pseudo-custom attribute. While the C# compiler will throw an error if you try to use the ParamArrayAttribute on a parameter rather than its keyword, the C# CodeDomProvider handles it. If you have a CodeParameterDeclarationExpression myMethodParam (of array type) and give it parameters with the following code:
myMethodParam.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute"));
then the C# provider will handle it: if you ask for code to be generated, you'll see a params keyword rather than the explicit attribute declaration, and if you compile directly to an assembly it will also work.
</SNIP>
I am using this with VS2008 and C# and it works like a charm.
Take care
Rene
| Rick Strahl West Wind Technologies Where do you want to surf today? | Reader Version: 5.0 |