468,457 Members | 1,603 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

Is dynamic code execution possible?

Hello,

I want to execute piece of code, which was created/loaded dynamically.
JScript/VBScript have this possibility via eval() method. How can I do
something similar in VB.NET? If I can't, then what are the alternatives?

A little background for my problem. I need to implement an application which
enumerates some data. On each data item it calls external plug-ins/hooks. I
need to implement these hooks as simple as possible. Ultimate goal is .js or
..vbs file with function that user will write. However, I don't know how to
execute this function from VB.NET.

Thanks in advance
Alex
Nov 20 '05 #1
7 4084
* "Alex Blekhman" <tkfx.DONTSENDSPAM.@yahoo.com> scripsit:
I want to execute piece of code, which was created/loaded dynamically.
JScript/VBScript have this possibility via eval() method. How can I do
something similar in VB.NET? If I can't, then what are the alternatives?


Untested: Maybe you can use the script control (VB6 sample):

<http://www.thescarms.com/vbasic/Scripting.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
* "Alex Blekhman" <tkfx.DONTSENDSPAM.@yahoo.com> scripsit:
I want to execute piece of code, which was created/loaded dynamically.
JScript/VBScript have this possibility via eval() method. How can I do
something similar in VB.NET? If I can't, then what are the alternatives?


Untested: Maybe you can use the script control (VB6 sample):

<http://www.thescarms.com/vbasic/Scripting.asp>


Thanks. It appears that Script Control is the way to do that.
Nov 20 '05 #3
On 2004-02-02, Alex Blekhman <tk***************@yahoo.com> wrote:
Hello,

I want to execute piece of code, which was created/loaded dynamically.
JScript/VBScript have this possibility via eval() method. How can I do
something similar in VB.NET? If I can't, then what are the alternatives?

A little background for my problem. I need to implement an application which
enumerates some data. On each data item it calls external plug-ins/hooks. I
need to implement these hooks as simple as possible. Ultimate goal is .js or
.vbs file with function that user will write. However, I don't know how to
execute this function from VB.NET.

Thanks in advance
Alex


Alex,

You may want to look at the System.Reflection and the
System.Reflection.Emit namespaces. These should let you load/create
code dynamically.

I'll look around a bit - it seems I found a good article on this not to
long ago.
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
It is easier to write an incorrect program than understand a correct one.
Nov 20 '05 #4
"Tom Shelton" <to*@mtogden.com> wrote in message
news:#o**************@tk2msftngp13.phx.gbl...

You may want to look at the System.Reflection and the
System.Reflection.Emit namespaces. These should let you load/create
code dynamically.


Thanks for pointer. I looked at it. At this time it's really overkill for my
project. MS Script Control suits my needs completely. BTW, the more I look
at .NET the more I'm impressed. These guys created a heck of universe
there..
Nov 20 '05 #5
In article <uT**************@TK2MSFTNGP10.phx.gbl>, Alex Blekhman wrote:
"Tom Shelton" <to*@mtogden.com> wrote in message
news:#o**************@tk2msftngp13.phx.gbl...

You may want to look at the System.Reflection and the
System.Reflection.Emit namespaces. These should let you load/create
code dynamically.


Thanks for pointer. I looked at it. At this time it's really overkill for my
project. MS Script Control suits my needs completely. BTW, the more I look
at .NET the more I'm impressed. These guys created a heck of universe
there..


That's cool... I just wanted to point out that there is an alternative
:)

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 4 Days, 21 Hours, 38 Minutes, 45 Seconds
Nov 20 '05 #6
Alex,
In addition to the others comments, you can use the classes in
System.CodeDom.Compiler, System.CodeDom along with
Microsoft.VisualBasic.VBCodeProvider to dynamically compile & execute VB.NET
source.

This article explains how:

http://msdn.microsoft.com/msdnmag/is...9/CuttingEdge/

Hope this helps
Jay

"Alex Blekhman" <tkfx.DONTSENDSPAM.@yahoo.com> wrote in message
news:eW**************@tk2msftngp13.phx.gbl...
Hello,

I want to execute piece of code, which was created/loaded dynamically.
JScript/VBScript have this possibility via eval() method. How can I do
something similar in VB.NET? If I can't, then what are the alternatives?

A little background for my problem. I need to implement an application which enumerates some data. On each data item it calls external plug-ins/hooks. I need to implement these hooks as simple as possible. Ultimate goal is .js or .vbs file with function that user will write. However, I don't know how to
execute this function from VB.NET.

Thanks in advance
Alex

Nov 20 '05 #7
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uG**************@TK2MSFTNGP09.phx.gbl...
Alex,
In addition to the others comments, you can use the classes in
System.CodeDom.Compiler, System.CodeDom along with
Microsoft.VisualBasic.VBCodeProvider to dynamically compile & execute VB.NET source.

This article explains how:

http://msdn.microsoft.com/msdnmag/is...9/CuttingEdge/

Thanks!
Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Ford Desperado | last post: by
6 posts views Thread by MattC | last post: by
60 posts views Thread by Peter Olcott | last post: by
reply views Thread by Pascal Costanza | last post: by
7 posts views Thread by Ronald S. Cook | last post: by
15 posts views Thread by EDBrian | last post: by
6 posts views Thread by =?ISO-8859-1?Q?Tim_B=FCthe?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.