Questions tagged [codedom]

CodeDOM is a framework which can be used to create an (abstract) expression tree representing real code structures (for example, classes, statements, etc.) in a language-independent way. This means if you construct an expression tree, you can use (or write) code generators to output the same logical structure in multiple different target languages. Language generators exist for VB.NET, C#, and JScript, but you can also create your own.

What is CodeDOM?

CodeDOM is a .NET library from Microsoft which:

  • Gives you a way to represent source code as expression objects

  • Provides some pre-built generators to translate the expressions into raw source code

  • Makes it easy to compile the generated source to executable code

Here is an excerpt from MSDN describing CodeDOM:

The CodeDOM provides types that represent many common types of source code elements. You can design a program that builds a source code model using CodeDOM elements to assemble an object graph. This object graph can be rendered as source code using a CodeDOM code generator for a supported programming language. The CodeDOM can also be used to compile source code into a binary assembly.

Some common uses for the CodeDOM include:

  • Templated code generation: generating code for ASP.NET, XML Web services client proxies, code wizards, designers, or other code-emitting mechanisms.

  • Dynamic compilation: supporting code compilation in single or multiple languages.

If you look into CodeDOM you will probably encounter a lot about abstract syntax trees (ASTs). This is the technical term for an expression tree in this context (originating from the way code generators, parsers, and compilers are written). If you plan to get into CodeDOM it helps to understand the basic concept; Wikipedia has a reasonable article on the subject.

What type of question should use this tag?

Questions should use this tag if they relate to the use, comprehension, or interaction with the CodeDOM library. It could also be used on questions relating to generation of code using a document object model (DOM) strategy similar to that provided by the Microsoft CodeDOM library.

Further Reading

593 questions
0
votes
1 answer

How to Build Composite Condition in CodeDOM to execute Rules

I am trying to build Rules with my custom UI and execute with CodeDom for my workflow module. I don’t want to use the Rules interface which is given with WF. In order to build/ execute a Rule, I am creating a Condition and ThenAction/ElseActions. …
Anil Karanam
  • 45
  • 1
  • 5
-1
votes
4 answers

programmatically code generation in C# using codedom

I want to generate code for creating a hash table object and assigning it with a key and a value programmatic . it should be similar to Hashtable ht = new Hashtable(); ht.Add( "key1", "value1" ); ht.Add( "key2", "value2" ); ht.Add( "key3",…
Arunachalam
  • 5,417
  • 20
  • 52
  • 80
-1
votes
1 answer

Execute or compile runtime c# code on textbox after changes event - "PlatformNotSupportedException"

I am wondering to provide an option in my application to users to be able to customize buttons in ASP.NET CORE with Blazor. I mean, C# code can be stored in database, and compiled/executed in runtime. How can I "provide" an object from razor to be…
thiagovinicius
  • 117
  • 1
  • 12
-1
votes
2 answers

Why does "params object[]" need passing as "new object[] { parameters }" for Com Method?

I've found lots of info on passing parameters to methods and found that having the method use params Object[] args to be a great (and sometimes only) way to do this. i.e. sample method: public void someMethod(params object[] args) { //do…
Joe
  • 616
  • 2
  • 12
  • 27
-1
votes
1 answer

vb.net Replace existing class with CodeDoms generated class

I've class like this (it's just example) class child inherits parent1 end class and then at runtime i want change become like this class child inherits grandfatherclass end class I've been trying with code like this, sadly it's still…
-1
votes
1 answer

When I open my compiled file it does nothing

I made a simple compiler to learn about CodeDom. But it does not work, when I try to open my compiled file it does nothing. When I run the code and slect an dir to save the exe file the exe file is generated, but when I click the exe file it does…
Gewoo
  • 437
  • 6
  • 19
-1
votes
2 answers

How to execute the code generated by codeDom?

I just generated the .cs file using codeDom. Can someone explain how do I execute it?
Ramya
  • 83
  • 1
  • 5
-1
votes
1 answer

CodeDom compiler does not use executable directory for assembly references

I have a CodeDom setup that needs to reference some assemblies that are in the executable's directory. However, it appears that only the Working Directory and the GAC are searched for these assemblies, and not the executable directory. var…
user7116
  • 63,008
  • 17
  • 141
  • 172
-1
votes
1 answer

Accessing WinForm Controls using C# dynamic code

I have WinForm called Form1 and there are Button1, MemoEdit1 and 2 TextBoxes named TextBox1 and TextBox2. At runtime user should be able write C# code in MemoEdit1 in order to manipulate the TextBox controls. F.e: at runtime user typed into…
Tim
  • 459
  • 1
  • 4
  • 20
-1
votes
1 answer

"An object reference is required for the non-static field, method or property." while compiling C# code at runtime

I have a public class, "CodeCompiler", which allows me to compile and run C# code at run-time. Just like IDEs work. When I click the "button1" it creates code at run-time, compiles and executes. My main Form1 contains a TextBox control called…
-1
votes
1 answer

Remove code from CodeDOM compilation at runtime

I have a Windows Forms Application with a CheckBox and a button. The button will make it so the CodeDOM compiled exe will disable task manager. But if they don't want it to disable, they can uncheck the button. What I'm trying to to is make it so if…
Meme Machine
  • 949
  • 3
  • 14
  • 28
-1
votes
1 answer

How to get names of loaded or referenced assemblies in the current app domain for passing to a C# compiler?

I was using this: AppDomain.CurrentDomain.GetAssemblies().SelectMany( a => a.GetModules().Select( m => m.FullyQualifiedName )).ToArray() to get the names of all loaded assemblies. It comes from code that gets a…
Triynko
  • 18,766
  • 21
  • 107
  • 173
-1
votes
2 answers

VB.NET Saving file without save dialog prompt

I need to know how I can save a file, without using save file dialog prompt. Currently my code is: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ProgressBar1.Value = 0 …
user2404495
  • 195
  • 1
  • 6
  • 17
-1
votes
2 answers

CodeDom Add File Properties?

Hello Guys I want to know how to add some File Properties (file creation date, description, file version etc...) to the output of the compiled code. I already know how to add an Icon : param.CompilerOptions += "/target:winexe" + " " + "/win32icon:"…
GumGun
  • 15
  • 1
  • 1
  • 5
-1
votes
1 answer

Resources in Winforms Application using CodeDOM

I have an application that deploys smaller applications. Those smaller ones basically consist of an icon (not a form icon) and a notifyicon control that needs an icon as well. My question is: How to embed resources in the small application and…
osos95
  • 169
  • 1
  • 10
1 2 3
39
40