Difference between revisions of "NET:Tutorials:HelloWorld"

From Lavish Software Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
== Introduction ==
+
== Notice ==
This Tutorial will help you configure Visual Studio 2005 and create your first .NET application.  This tutorial does not cover any .NET languages. (This tutorial will use Visual C# Express Edition) <BR>
+
The tutorial that was previously here is outdated and needs a complete rewrite. In the meantime, here's a quick step by step overview
If you don't have Visual Studio, you can use Visual C# Express Edition from Microsoft.
 
[http://msdn.microsoft.com/vstudio/express/visualcsharp/]
 
  
 
+
# Create .NET project
== Configuring the Project for Inner Space ==
+
# Reference Lavish.InnerSpace.dll to use Inner Space functionality in your .NET app (note: for it to work, the application has to be loaded via Inner Space, or the API will not perform any action). Reference Lavish.LavishNav.dll to use LavishNav functionality (same caveat)
 
+
# Import Lavish.InnerSpace.XML and Lavish.LavishNav.XML for complete Intellisense documentation of Inner Space and LavishNav functionality if desired
Once you have Visual Studio loaded, perform the following actions:
+
# Build application
* File -> New Project
+
# Place built executable (.exe) in InnerSpace\.NET Programs folder
* Choose Windows Application
+
# Launch application via Inner Space with the "dotnet" command, in the uplink or in the desired host session
* Name: ISXHelloWorld <BR>
 
** ''Note:  If you are creating a project that will need ISXWarden protection, the Project Name and all forms should be prefixed with ISX.''
 
* Click OK
 
 
 
At this point you should have your first .NET project!  In order to prepare the project to work with Inner Space perform the following actions: <BR>
 
Configure your application to use a <tt>Strong Name</tt>:
 
* Skip this step for Bytebot.net
 
* Project -> ISXHelloWorld Properties
 
* Choose the Signing Tab
 
* Check the Checkbox: Sign the Assembly
 
* Under the Choose a Strong Name Key File choose New...
 
* When the Create A Strong Key Name dialog Box appears choose a Key File Name.  You an also choose a password if you desire one.
 
 
 
Now that you have configured your application to use a Strong Name, configure your application to add itself to the Windows <tt>Global Assembly Cache</tt> automatically:
 
* Project -> ISXHelloWorld Properties
 
* Choose the Build Events Tab
 
* In the ''Post Build Events Command Line'' Window, enter the following code:
 
** "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)"
 
** "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /l "$(ProjectName)">"$(ProjectDir)name.txt"
 
**(Update the path of .NET 2.0 to match yours if you choose a different installation directory)
 
When you build your project, You will have a file in your project directory called name.txt.  This is the information you will use later to launch your assembly from within Inner Space.
 
 
 
Configure your application with a reference to the Lavish.InnerSpace.dll library
 
* Project -> Add Reference
 
* Choose the Browse Tab
 
* Browse to your Inner Space installation directory
 
* Select the Lavish.InnerSpace.dll file and choose OK
 
<BR>
 
After following these steps, your project is now ready to run within Innerspace!
 
 
 
 
 
<BR>
 
* These might work better for all installs of VS on diffrent languages of windows. /me
 
** "$(DevEnvDir)..\..\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)"
 
** "$(DevEnvDir)..\..\SDK\v2.0\Bin\gacutil.exe" /l "$(ProjectName)">"$(ProjectDir)name.txt"
 
 
 
== Code Time ==
 
Your application can be compiled and run in Inner Space, but it isn't going to do much yet.  So I will show a quick "Hello World" application to show the basics of working within Inner Space.
 
 
 
Follow these steps to configure your form:
 
* Place a label on the form
 
** Configure the text property of the Label with the following text: "Hello World!"
 
<BR>
 
* Place a Button on the form
 
** Configure the text property of the Button with the following text: "Close"
 
<BR>
 
* Double Click the button on the form to add code to handle the Button1.OnClick Event
 
 
 
Add the InnerSpaceAPI namespace to your code:
 
* At the top of the code form, add the following code under the other USING commands
 
using InnerSpaceAPI;
 
 
 
Add code to the Button1_Click Code to say goodbye and close our application:
 
*  In the Button1_Click function, add the following code
 
InnerSpaceAPI.InnerSpace.Echo("Goodbye World!");
 
Application.Exit();
 
This will say Goodbye World! in the console, and unload!
 
 
 
At this point you are ready to compile your application!
 
 
 
=== ISXHelloWorld code ===
 
Here is the complete code listing for the application:
 
 
 
using System;
 
using System.Collections.Generic;
 
using System.ComponentModel;
 
using System.Data;
 
using System.Drawing;
 
using System.Text;
 
using System.Windows.Forms;
 
using InnerSpaceAPI;  //Namespace for InnerSpaceAPI
 
namespace ISXHelloWorld
 
{
 
    public partial class Form1 : Form
 
    {
 
        public Form1()
 
        {
 
            InitializeComponent();
 
        }
 
        private void button1_Click(object sender, EventArgs e)
 
        {
 
            //Say goodbye!
 
            InnerSpace.Echo("Goodbye World!");
 
            Application.Exit();
 
        }
 
    }
 
}
 
 
 
== Running ISXHelloWorld ==
 
Running your application is pretty straight forward, but you need a bit of information first.  Open the name.txt file in your project directory and copy the line that looks similar to this:
 
ISXHelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad2c3650b019fe4b, processorArchitecture=MSIL
 
 
 
In the Inner Space Console in game, simply type the command:
 
DotNet hello "ISXHelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad2c3650b019fe4b, processorArchitecture=MSIL"
 
 
 
Hint: Copy and paste the text in the "" from your name.txt file.
 
 
 
== TODO: ==
 
Add Screenshots and clean up formatting.
 
 
 
--[[User:BlizzWishes|BlizzWishes]] 22:20, 1 December 2006 (EST)
 

Latest revision as of 14:02, 6 April 2008

Notice

The tutorial that was previously here is outdated and needs a complete rewrite. In the meantime, here's a quick step by step overview

  1. Create .NET project
  2. Reference Lavish.InnerSpace.dll to use Inner Space functionality in your .NET app (note: for it to work, the application has to be loaded via Inner Space, or the API will not perform any action). Reference Lavish.LavishNav.dll to use LavishNav functionality (same caveat)
  3. Import Lavish.InnerSpace.XML and Lavish.LavishNav.XML for complete Intellisense documentation of Inner Space and LavishNav functionality if desired
  4. Build application
  5. Place built executable (.exe) in InnerSpace\.NET Programs folder
  6. Launch application via Inner Space with the "dotnet" command, in the uplink or in the desired host session