Hosting the CLR (.Net)

Started by
6 comments, last by Shannon Barber 21 years, 7 months ago
I''ve been reading about hosting the CLR, and how to setup it and create domains, then load some .Net assemblies. I also read a little bit about Reflection.Emit which I believe how you would hook-in a custom scripting language. I''m kinda lazy though, I would rather not go through all the trouble of making a custom compiler & language if I can just have clients use C#. Is there anything in the framework to compile .cs source files? Or do you have to buy Visual Studio and use it''s compiler? I see there''s a new VSA .Net SDK (comparable to the old VBA SDK), does anyone know how much this beast cost? What are the viable options for integrating .Net scripting into a game (or other non-multi-billion dollar software)? ... Ah cool, I was looking for this Friday: NI Measurement Studio for .Net
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
To compile .cs files use csc.exe...it''s found within the framwork.
I guess it''s kind-of a stupid question - I''m looking for a way to compile C# code without Visual Studio.

Everything I read about requires the end-user to buy a license for it.

Seems the simplest thing to do is make a Visual Studio .Net Add-In. The VSI/VSIP/VSA look like they cost a small fortune.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
csc is free in the .NET SDK. If you want a free C# compiler written in C# that is Open Source check out www.go-mono.com
Magmai, take a look at this: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=478. This is a class I wrote to use as a scripting engine in a project I am working on. It uses the Microsoft.*.Vsa namespaces to support JScript.NET as a scripting language. All these classes are in the framework, so theres no extra download. However, the documentation is sort of sparse.
I am sort of tired now, but the class should be fairly well commented. If you have any questions, just post them and I''ll take a look tomorrow.

"When you know the LORD you have no need for masturbation!"
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
System.CodeDom.Compiler.ICodeCompiler compiler = new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler();System.CodeDom.Compiler.CompilerResults results;System.Reflection.Assembly compiledAsm;//this compiles from a string...results = compiler.CompileAssemblyFromSource(new System.CodeDom.Compiler.CompilerParameters(), @"namespace test { public class myTest { public int Foo; } }");//results.Errors - all compile errors...//results.CompiledAssembly...if compilation is successful the assembly to late-bind tocompiledAsm = results.CompiledAssembly;//or this to compile from a fileresults = compiler.CompileAssemblyFromFile(new System.CodeDom.Compiler.CompilerParameters(), @"C:\script.cs");  


Epolevne


[edit: a line of code was too long, broke into two lines]

[edited by - Magmai Kai Holmlor on September 3, 2002 2:23:37 PM]
Sweet!
Now, if you could help me limp along here; I know you use #using to access .Net stuff in C++, but how do you figure out what to #use?

You have to have a #using <mscorlib.dll>, but what/where do I find what to add to access CodeDOM?

#using <System.CodeDOM.dll> doesn't work...
nor does #using <Microsoft.CSharp.dll> or #using <Microsoft.CSharp.CSharpCodeProvider.dll>


Ahh nevermind, it appears everything is brought in by #using <System.dll>

[edited by - Magmai Kai Holmlor on September 3, 2002 2:56:12 PM]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
To answer this in general: READ THE DOCUMENTATION.

When I look at the description of a class, it tells me at the lower end of the page:

(a) which namespace the class resides in and
(b) which dll contains the class.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)

This topic is closed to new replies.

Advertisement