473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dynamic creation and execution of code

JC
Hello,

I'm looking for examples of how to make dynamic creation
of code and dynamic execution of the same code. I want to
do some code dynamically and then I want to use it to get
some results. Then I want to store the C# code in a
database.
I found an example explaining how to do a sum of 100
numbers. What I didn't understand was the way to
generalize it's use.
Any solutions fot this ?

Thanks.
Nov 15 '05 #1
2 2044
> I'm looking for examples of how to make dynamic creation
of code and dynamic execution of the same code. I want to
do some code dynamically and then I want to use it to get
some results. Then I want to store the C# code in a
database.
I found an example explaining how to do a sum of 100
numbers. What I didn't understand was the way to
generalize it's use.
Any solutions fot this ?


after the source is compiled to memory, you can use reflection to analyze
the compiled assembly and use Delegate.CreateDelegate method to dynamically
create a delegate from compiled code.
then, using the delegate, you can use the code in the runtime. the delegate
can have any prototype and the Delegate.CreateDelegate method will check if
you create a delegate from proper method from the compiled code.
regards, Wiktor


Nov 15 '05 #2
JC,

In addition to what Wiktor said, I think that this is a bad idea, to try
and dynamically create code and then execute it (it's also a pain). If you
are going to insist on using dynamically generated code, then you probably
should at least define an interface which can always be bound to by the
caller, which the dynamically generated code must implement. This will make
it easer to access the code.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JC" <j.************@telecom.pt> wrote in message
news:33****************************@phx.gbl...
Hello,

I'm looking for examples of how to make dynamic creation
of code and dynamic execution of the same code. I want to
do some code dynamically and then I want to use it to get
some results. Then I want to store the C# code in a
database.
I found an example explaining how to do a sum of 100
numbers. What I didn't understand was the way to
generalize it's use.
Any solutions fot this ?

Thanks.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK'...
2
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page....
15
by: rwf_20 | last post by:
I just wanted to throw this up here in case anyone smarter than me has a suggestion/workaround: Problem: I have a classic producer/consumer system which accepts 'commands' from a socket and...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
1
by: Tim Silva | last post by:
SDX Modeling, Simulation and Numerical Computing Environment for science and engineering has now been released. Major features include: * A unified simulation environment for modeling virtually...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
5
by: Ronald S. Cook | last post by:
I've read a few posts on the stored procedure vs dynamic sql debate. I ran a few performance test for myself and it appears to be a wash. Given that, I'm leaning toward dynamic sql mostly...
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.