Single statement execution

  • Thread starter Thread starter Sorawit Sharp
  • Start date Start date
S

Sorawit Sharp

My app executes C# user scripts via dynamic code execution.
Is it possible to execute the scripts single step wise like a debugger ?
 
Sorawit,

What do you mean C# user scripts? Chances are, no, you can not. You
need to step through compiled code that has debug symbols that you have the
source for. But you say you have scripts, which indicates you have
something else.
 
My problem description was inaccurate: The user of the app sees something
similar like scripts.
More precisely I'm talking about pieces of C# sharp code which the app
compiles and executes:

using System.CodeDom.Compiler;

ICodeCompiler theCompiler = new
Microsoft.CSharp.CSharpCodeProvider().CreateCompiler();
CompilerResults theResults =
theCompiler.CompileAssemblyFromSource(theCompilerParms, theSourceCode);
:
Assembly theAssembly = theResults.CompiledAssembly();
MethodInfo theMethodInfo = theAssembly.EntryPoint;
theMethodInfo.Invoke(null, theInvokeParms);

The Invoke() method executes this 'user script'. What I'm looking for is a
way to execute this code statement by statement.

Thanks for your response.
 
Sorawit,
It sounds like you may want to use VSA, unfortunately last I heard VSA was
discontinued and I have not heard of a replacement. VSA = Visual Studio for
Applications.

I'm not sure if VSIP http://msdn.microsoft.com/vstudio/extend/ offers
anything usable for you. As VSIP is more about integrating your code into VS
instead of integrating VS into your app.

I thought MSDN Magazine had an article on using the debugging & profileing
COM based APIs for .NET, however I'm not seeing anything obvious right now.

Hope this helps
Jay
 
Dynamic code execution is an inherent .NET technology.

Regarding VBScript, which requires the VSA-Runtime, we got the notion that
Microsoft is not that enthusiastic like it used to be. It sounds like a past
technology.
 
Fully agree with your statements.
Luckily this app is going to be used by a very limited audience. It's a kind
of programming tool in a special environment where the users are supposed to
be skilled enough.
 
Patty,
What happens when the "user" is a developer?

How would you handle applications such as ACT - Application Center Test,
where you enter scripts that are used for stress & performance testing your
web site?

What about tools such as Robocode, that gives you a limited IDE that allows
you to create robots based on Java. I could easily see a VB.NET or C# based
one that allows you to teach .NET development in a similar limited & fun
environment.

Hope this helps
Jay
 
Sorawit,

I can't say that I agree with this statement completely. Granted, there
is JScript, but it bends over backwards to provide this kind of ability.

Dynamic code execution is inherent in the context of the CLR, it does a
ton of this stuff, but as far as the developer is concerned, .NET should not
be seen as a platform for doing this.
 
Sorawit said:
My app executes C# user scripts via dynamic code execution.
Is it possible to execute the scripts single step wise like a debugger ?

I have not actually used any of the debugger APIs in the framework, but
these sources of information might be useful to helping you do what you
want:

A Microsoft CLR Managed Debugger (mdbg) Sample:

http://www.microsoft.com/downloads/...42-6b7a-4e28-80ce-c55645ab1310&displaylang=en


Jon Shute's weblog:

http://blogs.chimpswithkeyboards.com/jonshute/category/2.aspx
 
Back
Top