HighTechTalks DotNet Forums  

Is it possible to write a scripting engine in C#?

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss Is it possible to write a scripting engine in C#? in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
eval.apply@gmail.com
 
Posts: n/a

Default Is it possible to write a scripting engine in C#? - 09-10-2007 , 03:40 PM






I decided to try writing a scripting engine in C#. I've written some
code, put in the annotations for ComInterop, added the regsitry
settings and it *almost* works. CScript, WScript, and IE can all find
the script engine and call the first few methods correctly. It is
clear that they are correctly getting a hold of both the IActiveScript
and IActiveScriptParse interfaces. But after the first few method
calls, they all quit. CScript raises this error:

CScript Error: Can't find script engine "LScript" for script
"hello.ls".

WScript raises an analagous error, and IE calls InitNew,
SetScriptSite, GetScriptState, SetScriptState, and Close. None of the
hosts seem to call AddNamedItem, which is what I expect would be next.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

Anyone have any suggestions?


Reply With Quote
  #2  
Old   
asdf
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-15-2007 , 04:13 AM






"When I write my own scripting host in C++"


Kudos

------------------------------------------------------

Where have you been ?

"I write my own scripting host in C++"

Where have you been ?


------------------------------------------------------

Because it is not working well, ain't it.

not because you had an opinion long ago.

------------------------------------------------------

The world will have to absorb your mess.

Not the other way around, you will find out.








<eval.apply (AT) gmail (DOT) com> wrote

Quote:
I decided to try writing a scripting engine in C#. I've written some
code, put in the annotations for ComInterop, added the regsitry
settings and it *almost* works. CScript, WScript, and IE can all find
the script engine and call the first few methods correctly. It is
clear that they are correctly getting a hold of both the IActiveScript
and IActiveScriptParse interfaces. But after the first few method
calls, they all quit. CScript raises this error:

CScript Error: Can't find script engine "LScript" for script
"hello.ls".

WScript raises an analagous error, and IE calls InitNew,
SetScriptSite, GetScriptState, SetScriptState, and Close. None of the
hosts seem to call AddNamedItem, which is what I expect would be next.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

Anyone have any suggestions?



Reply With Quote
  #3  
Old   
mayayana
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-15-2007 , 08:43 AM



Quote:
I decided to try writing a scripting engine in C#.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

So why would you try to do it in C#, adding up to
100 MB of dependencies and slowing down script even
worse than it is already? One doesn't write a script
enigine in .Net for the same reason that one doesn't
write most desktop software, drivers, disk uitilities, etc.
in .Net or Java: It's slow, uncompiled, and once removed
from the API. It's software running software running
software.




Reply With Quote
  #4  
Old   
John Vottero
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-17-2007 , 12:02 PM



"mayayana" <mayaXXyana1a (AT) mindXXspring (DOT) com> wrote

Quote:
I decided to try writing a scripting engine in C#.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.


So why would you try to do it in C#, adding up to
100 MB of dependencies and slowing down script even
worse than it is already? One doesn't write a script
enigine in .Net for the same reason that one doesn't
write most desktop software, drivers, disk uitilities, etc.
in .Net or Java: It's slow, uncompiled, and once removed
from the API. It's software running software running
software.
Well, PowerShell is a pretty nice scripting engine and it's written in C#.
That 100MB of dependencies includes some very useful stuff.



Reply With Quote
  #5  
Old   
mayayana
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-18-2007 , 11:21 AM




Quote:
Well, PowerShell is a pretty nice scripting engine and it's written in C#.
That 100MB of dependencies includes some very useful stuff.

Are you sure it's not actually written in C++?
I know the "cmdlets" are .Net classes, but I would
guess that the shell itself is actual compiled
software.

I don't know much about Powershell, as it requires
XP SP2, .Net 2.0, and also requires submitting to the
installation of the WGA spyware. So far I haven't had any
reason to deal with any of those things. I guess that
Powershell must have some useful things for network
administrators, but frankly I'm baffled at why any significant
number of people would actually want to revert to the
primitive inconvenience of a DOS/UNIX-style command line
interface. (That's what I'm waiting for Linux to outgrow.
Especially when it involves so many limitations and dependencies,
and also involves learning yet again another new syntax and
set of keywords. Maybe it's nostalgia? Maybe people just
feel like they're running "close to the metal" when they
type abstruse commands into black windows?

And you yourself are running on Vista. You've paid an
extra $300+- to get 3-D techno-kitsch graphics on your
Desktop, yet you prefer to work out of a terminal
window? I don't get it.

In any case, creating "DOS 2.0" as a set of something
akin to Java applets doesn't strike me as a particularly
clever design.




Reply With Quote
  #6  
Old   
John Vottero
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-18-2007 , 08:53 PM



"mayayana" <mayaXXyana1a (AT) mindXXspring (DOT) com> wrote

Quote:

Well, PowerShell is a pretty nice scripting engine and it's written in
C#.
That 100MB of dependencies includes some very useful stuff.


Are you sure it's not actually written in C++?
I know the "cmdlets" are .Net classes, but I would
guess that the shell itself is actual compiled
software.
The whole thing is written in C#.

Quote:
I don't know much about Powershell, as it requires
XP SP2, .Net 2.0, and also requires submitting to the
installation of the WGA spyware. So far I haven't had any
reason to deal with any of those things. I guess that
Powershell must have some useful things for network
administrators, but frankly I'm baffled at why any significant
number of people would actually want to revert to the
primitive inconvenience of a DOS/UNIX-style command line
interface. (That's what I'm waiting for Linux to outgrow.
Especially when it involves so many limitations and dependencies,
and also involves learning yet again another new syntax and
set of keywords. Maybe it's nostalgia? Maybe people just
feel like they're running "close to the metal" when they
type abstruse commands into black windows?
GUIs are great until you have to do something more than once.

Quote:
And you yourself are running on Vista. You've paid an
extra $300+- to get 3-D techno-kitsch graphics on your
Desktop, yet you prefer to work out of a terminal
window? I don't get it.
If you want to develop software that's "Certified for Windows Vista", you
really need to run Vista.

Quote:
In any case, creating "DOS 2.0" as a set of something
akin to Java applets doesn't strike me as a particularly
clever design.

Ok, "cmdlets" and "applets" both end in "lets" but, that's the only
similarity.



Reply With Quote
  #7  
Old   
Ken Foust
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 09-19-2007 , 08:53 AM



On Sep 10, 3:40 pm, eval.ap... (AT) gmail (DOT) com wrote:
Quote:
I decided to try writing a scripting engine in C#. I've written some
code, put in the annotations for ComInterop, added the regsitry
settings and it *almost* works. CScript, WScript, and IE can all find
the script engine and call the first few methods correctly. It is
clear that they are correctly getting a hold of both the IActiveScript
and IActiveScriptParse interfaces. But after the first few method
calls, they all quit. CScript raises this error:

CScript Error: Can't find script engine "LScript" for script
"hello.ls".

WScript raises an analagous error, and IE calls InitNew,
SetScriptSite, GetScriptState, SetScriptState, and Close. None of the
hosts seem to call AddNamedItem, which is what I expect would be next.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

Anyone have any suggestions?
I'm not quite sure what you're doing, but I'll throw in my two cents.

1. First off, yes you can create a scripting engine in C#. I've even
seen some incomplete examples on the web for just this, though I don't
remember the sites. Since you can multithread in C#, you should also
be able to integrate the IActiveScriptDebug interfaces as well.

2. If you have the engine already built in C++ why not just make this
an OLE object and use this from your C#.

3. There is a lot of negative issues with the script engine - its
depracating technology and any .NET objects passed to the script need
to be visible via COM interop.

4. A better scripting solution would be to just use the .NET designer/
compilation objects provided in the framework to create true .NET code
and execute that.

5. If you're die-hard set to use a scripting engine I'd purchase one -
several are available. The one I wrote is available at www.orangesoftwaredesigns.com,
though I've not got the site completed yet - I've only recently
decided to start selling the engine. Let me know if you're interested
in that option.



Reply With Quote
  #8  
Old   
Blue Streak
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 10-02-2007 , 11:55 AM



On Sep 19, 8:53 am, Ken Foust <ken_fo... (AT) hotmail (DOT) com> wrote:
Quote:
On Sep 10, 3:40 pm, eval.ap... (AT) gmail (DOT) com wrote:





I decided to try writing a scripting engine in C#. I've written some
code, put in the annotations for ComInterop, added the regsitry
settings and it *almost* works. CScript, WScript, and IE can all find
the script engine and call the first few methods correctly. It is
clear that they are correctly getting a hold of both the IActiveScript
and IActiveScriptParse interfaces. But after the first few method
calls, they all quit. CScript raises this error:

CScript Error: Can't find script engine "LScript" for script
"hello.ls".

WScript raises an analagous error, and IE calls InitNew,
SetScriptSite, GetScriptState, SetScriptState, and Close. None of the
hosts seem to call AddNamedItem, which is what I expect would be next.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

Anyone have any suggestions?

I'm not quite sure what you're doing, but I'll throw in my two cents.

1. First off, yes you can create a scripting engine in C#. I've even
seen some incomplete examples on the web for just this, though I don't
remember the sites. Since you can multithread in C#, you should also
be able to integrate the IActiveScriptDebug interfaces as well.

2. If you have the engine already built in C++ why not just make this
an OLE object and use this from your C#.

3. There is a lot of negative issues with the script engine - its
depracating technology and any .NET objects passed to the script need
to be visible via COM interop.

4. A better scripting solution would be to just use the .NET designer/
compilation objects provided in the framework to create true .NET code
and execute that.

5. If you're die-hard set to use a scripting engine I'd purchase one -
several are available. The one I wrote is available atwww.orangesoftwaredesigns.com,
though I've not got the site completed yet - I've only recently
decided to start selling the engine. Let me know if you're interested
in that option.- Hide quoted text -

- Show quoted text -
For examples that work Google the following: C# Script, Dot Net
Script, NScript. Or you could just go to www.codeproject.com.



Reply With Quote
  #9  
Old   
Piter
 
Posts: n/a

Default Re: Is it possible to write a scripting engine in C#? - 10-19-2007 , 02:37 AM



For this purpose you can try Script.NET, it is available with source code.
Here is a link: http://www.protsyk.com/scriptdotnet

"Blue Streak" wrote:

Quote:
On Sep 19, 8:53 am, Ken Foust <ken_fo... (AT) hotmail (DOT) com> wrote:
On Sep 10, 3:40 pm, eval.ap... (AT) gmail (DOT) com wrote:





I decided to try writing a scripting engine in C#. I've written some
code, put in the annotations for ComInterop, added the regsitry
settings and it *almost* works. CScript, WScript, and IE can all find
the script engine and call the first few methods correctly. It is
clear that they are correctly getting a hold of both the IActiveScript
and IActiveScriptParse interfaces. But after the first few method
calls, they all quit. CScript raises this error:

CScript Error: Can't find script engine "LScript" for script
"hello.ls".

WScript raises an analagous error, and IE calls InitNew,
SetScriptSite, GetScriptState, SetScriptState, and Close. None of the
hosts seem to call AddNamedItem, which is what I expect would be next.

When I write my own scripting host in C++, there is no problem ---
everything works just fine.

Anyone have any suggestions?

I'm not quite sure what you're doing, but I'll throw in my two cents.

1. First off, yes you can create a scripting engine in C#. I've even
seen some incomplete examples on the web for just this, though I don't
remember the sites. Since you can multithread in C#, you should also
be able to integrate the IActiveScriptDebug interfaces as well.

2. If you have the engine already built in C++ why not just make this
an OLE object and use this from your C#.

3. There is a lot of negative issues with the script engine - its
depracating technology and any .NET objects passed to the script need
to be visible via COM interop.

4. A better scripting solution would be to just use the .NET designer/
compilation objects provided in the framework to create true .NET code
and execute that.

5. If you're die-hard set to use a scripting engine I'd purchase one -
several are available. The one I wrote is available atwww.orangesoftwaredesigns.com,
though I've not got the site completed yet - I've only recently
decided to start selling the engine. Let me know if you're interested
in that option.- Hide quoted text -

- Show quoted text -

For examples that work Google the following: C# Script, Dot Net
Script, NScript. Or you could just go to www.codeproject.com.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.