Click here to Skip to main content
15,893,968 members
Articles / Programming Languages / XML

Dot Net Script

Rate me:
Please Sign up or sign in to vote.
4.74/5 (64 votes)
18 Mar 200411 min read 425.2K   6.8K   167  
Write and execute C# or VB.NET as if they were scripting languages (using the CodeDom)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

	<!-- This defines the three custom config sections -->	
	<configSections>
		<sectionGroup name="referencedAssemblies">
			<section name="assembly" 
				type="DotNetScriptEngine.DotNetScriptAssemblySectionHandler, DotNetScriptEngine" allowLocation="false"/>			
		</sectionGroup>
		
		<sectionGroup name="supportedLanguages">
			<section name="language" 
				type="DotNetScriptEngine.DotNetScriptLanguageSectionHandler, DotNetScriptEngine" allowLocation="false"/>
		</sectionGroup>	
		
		<section name="userPreferences" 
			type="DotNetScriptEngine.DotNetScriptUserPreferencesSectionHandler, DotNetScriptEngine" allowLocation="false"/>								
	</configSections>
	
	
	<!-- Use this section to add default assemblies that will be referenced by every script -->
	<!-- If the assembly is in the GAC you dont have use the full path name -->
	<referencedAssemblies>
		<assembly path="System.dll" />
		<assembly path="System.Messaging.dll" />
		<assembly path="System.Security.dll" />
	</referencedAssemblies>
	
	
	<!-- This section alows you to add new .Net languages to the script engine without modifying the source code -->
	<!-- Note: VB and C# are built into the engine, all other languages need to be defined (or you could modify the engine) -->
	<!-- name: This is the name that you enter in the script file or in the default language section below -->
	<!-- assembly: This is the full path to the assembly file that contains the language specific code provider class -->
	<!-- codeProviderName: This is the full name, including namespace, of the code provider class -->
	<supportedLanguages>		
		<language name="JScript" assembly="C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Microsoft.JScript.dll" 
			codeProviderName="Microsoft.JScript.JScriptCodeProvider" />
		<language name="J#" assembly="c:\winnt\microsoft.net\framework\v1.1.4322\vjsharpcodeprovider.dll" 
			codeProviderName="Microsoft.VJSharp.VJSharpCodeProvider" />
	</supportedLanguages>
	
	
	<!-- defaultLanguage can only be C#, VB or whatever name you give in the language element -->
	<!-- true keeps the Console window open after script if finished, flase closes automatically-->
	<!-- this is the function that will be called first when the script is run -->
	<userPreferences defaultLanguage="C#" entryPoint="Main" waitForUserAction="true" />	
	
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
United States United States
I have been a professional developer since 1996. My experience comes from many different industries; Data Mining Software, Consulting, E-Commerce, Wholesale Operations, Clinical Software, Insurance, Energy.

I started programming in the military, trying to find better ways to analyze database data, eventually automating my entire job. Later, in college, I automated my way out of another job. This gave me the great idea to switch majors to the only thing that seemed natural…Programming!

Comments and Discussions