
Signature
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------
>I am building an application that is totally data driven. The pages are
> built from scratch at runtime.I have everything working fine. Now all I
> need to do is to have the ability to add code both server-side and
> client-sie at runtime. I think I have pretttty much figured out the
> client side part. My problem is the servre-side code. How do i inject
> and/or run server-side code (frfom the database) at runtime?
Thx
I will try this
And yes, I am generating code on the fly
sw
> Are you generating C#/VB.Net code on the fly?
> Yikes! Well... you would be needing
[quoted text clipped - 18 lines]
> > client side part. My problem is the servre-side code. How do i inject
> > and/or run server-side code (frfom the database) at runtime?
dave.dolan - 23 Aug 2006 18:24 GMT
Don't forget about DynamicMethod. You can create a delegate to an arbitrary
method, constructor, or property accessor anywhere... and it works lots
faster than the Invoke on MethodInfo via reflection. (You can cache
delegates in a dictionary, for example, and have the ability to access
properties or methods by a string name)
There is an introduction to this type of thing on a CodeProject article:
http://www.codeproject.com/csharp/DynamicMethodDelegates.asp?print=true
There's also something on MSDN about it, but it's not very helpful.
If you want to get really fancy and use generics that determine their type
parameters at runtime, then you'll have to do something like this :
http://musingmarc.blogspot.com/2006/08/how-to-do-late-dynamic-method-creation.html (Marc is one of my newfound hero's)
> Thx
> I will try this
[quoted text clipped - 23 lines]
> > > client side part. My problem is the servre-side code. How do i inject
> > > and/or run server-side code (frfom the database) at runtime?
MRe - 24 Aug 2006 14:33 GMT
I found http://www.west-wind.com/presentations/dynamicCode/DynamicCode.htm
to be a pretty good reference on doing this.. put me right off the idea :)
You could also use the Script control (though you'll have to use vbscript or
javascript) - Add a reference to the COM \ Microsoft Script Control 1.0 and
do like..
<snip>
ScriptControl script = new ScriptControl();
script.Language = "vbscript";
script.AddObject("joe", new ken(), true);
Response.Write(script.Eval("(1 + 3) * joe.bob"));
</snip>
[ComVisible(true)]
public partial class ken
{
public int bob = 3;
}
..too easy!
Regards,
Eliott
| Thx
| I will try this
[quoted text clipped - 23 lines]
| > > client side part. My problem is the servre-side code. How do i inject
| > > and/or run server-side code (frfom the database) at runtime?