Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 863

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="16. Runtime Hosting" />
  <meta name="dc.subject" content="16. Runtime Hosting" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="runtimehosting.html" title="Chapter Contents" />
  <link rel="prev" href="rthactivation.html" title="Runtime Environments" />
  <link rel="next" href="rthclrmono.html" title="CLR &amp; Mono" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>16. Runtime Hosting</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="rthclr" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>16. Runtime Hosting</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="runtimehosting.html">Chapter Contents</a> | <a class="link" href="rthactivation.html" title="Runtime Environments">Prev</a> | <a class="link" href="rthclrmono.html" title="CLR &amp; Mono">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="runtimehosting.html">Runtime Hosting</a>
   </div>
    <br />
   <div>
      <a href="rthactivation.html">Runtime Environments</a>
   </div>
   <div class="selected">
      <a href="rthclr.html">CLR, .Net &amp; ASPX Host</a>
    <div>
        <a href="#rthclrenvsetdotnet" title="Environment Setup">Environment Setup</a>
        <a href="#rthclrdotnettest" title="Testing the Virtuoso .NET Runtime Environment">Testing the Virtuoso .NET Runtime Environment</a>
    </div>
   </div>
   <div>
      <a href="rthclrmono.html">CLR &amp; Mono</a>
   </div>
   <div>
      <a href="javaextvm.html">Embedded Java VM API</a>
   </div>
   <div>
      <a href="cinterface.html">Virtuoso Server Extension Interface (VSEI) (C Interface)</a>
   </div>
   <div>
      <a href="vseplugins.html">VSEI Plugins</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="rthclr" />
    <h2>16.2. CLR, .Net &amp; ASPX Host</h2>
 <p>The Common Language Runtime (CLR) is the foundation upon which the
 Microsoft® .NET strategy is built.  The CLR provides an execution environment
 that manages running code and provides services that make software development
 easier.  These services include automatic memory management, cross-language
 integration, interoperability with existing code and systems, simplified
 deployment, and a fine grained security system.  The .NET platform also
 brings with it a new programming language called C#.  It is very similar to Java
 and allows developers to make full use of all features available on the .NET runtime.</p>

 <p>The CLR can run a variety of different types of applications, such as:
 console applications, Web server scripts, traditional Win32-based applications,
  and more.</p>

<p>The CLR provides a language specification for compilers to generate classes
 and code that can interoperate with other programming languages (The
 Common Language Specification: CLS) .  Any API that is written using a
 CLS provider language can be used by any language that is a CLS consumer.
 Compilers generate code in a format called Common Intermediate Language
 (CIL) which is an intermediate representation of a compiled program and is
 easy to compile to native code or be compiled using Just-in-Time (JIT)
 engines.  The restrictions placed by the runtime on the CIL byte codes
 ensures good potential for code optimization by the JIT compiler.  The runtime
 environment provides garbage collection, threading and a comprehensive class
 library.  All these things make code development easier and more appealing
 by allowing a mixture of languages to be collaborating to produce results, all
 contained within a managed sandbox to prevent bugs from breaking other running
 programs.</p>

 <p>Windows has compilers that target the virtual machine from a number
 of languages: Managed C++, JavaScript, Eiffel, Component Pascal, APL, Cobol,
 Perl, Python, Ruby, Scheme, Smalltalk, Standard ML, Haskell, Mercury and Oberon. </p>

 <p>Virtuoso is a CLR host.  It is responsible for initializing the runtime,
 defining the application domain (its runtime boundaries, security settings, etc),
 and executing user code within such domains.  Windows can be used
 as the development platform, a very developer friendly environment with
 a rich set of tools, but you  will not be restricted to Windows, .NET
 and IIS to run the assemblies produced.  Where .NET is not readily available
 or desired Virtuoso contains Mono, an open source re-implementation of
 Microsoft .NET, a vehicle making .NET cross-platform.  </p>

 <p>The CLR run time is a part of the Virtuoso process.  The Mono run time may be
run either as in-process or as out-of-process.  Hosted applications can make use of
the regular Virtuoso .net data provider to access Virtuoso SQL data and procedures.
 Microsoft ASPX files can also be run directly from Virtuoso either from
 the filesystem or WebDAV.  Each of these capabilities releases you from
 the Microsoft platforms without compromising your development platform.</p>





 <a name="rthclrenvsetdotnet" />
    <h3>16.2.1. Environment Setup</h3>
 <p>Follow the steps below to configure the CLR runtime environment
 with Virtuoso:</p>

 <ol>
      <li>
        <div class="formalpara">
          <strong>Install .Net Framework SDK</strong>
  <p>The .Net Framework can be downloaded from the Microsoft web site.</p>
  </div>
  </li>
      <li>
        <div class="formalpara">
          <strong>Install virtclr.dll into the GAC</strong>
  <p>The <span class="computeroutput">virtclr.dll</span> library supplied with
  Virtuoso must be installed into the .Net &#39;Global Assembly Cache (GAC)&#39;.</p>
  </div>
  <p>.Net library components can be installed into the GAC using the command:
  <span class="computeroutput">gacutil /i &lt;DLL&gt;</span>.  The gacutil utility is supplied
  with the .Net framework.  In this case we would use the command:</p>
  <div>
          <pre class="programlisting">gacutil /i virtclr.dll</pre>
        </div>
  </li>
      <li>
     <div class="formalpara">
          <strong>Register virtclr with COM</strong>
  <p>The virtclr.dll library must be registered as COM object  using the
  &#39;regasm&#39; utility as follows:</p>
     </div>
  <div>
          <pre class="programlisting">regasm virtclr.dll</pre>
        </div>
  </li>
      <li>
        <div class="formalpara">
          <strong>Install virt_http.dll into the GAC</strong>
  <p>The <span class="computeroutput">virt_http.dll</span> library supplied with
  Virtuoso must be installed into the .Net &#39;Global Assembly Cache (GAC)&#39;.</p>
  </div>
  <div>
          <pre class="programlisting">gacutil /i virt_http.dll</pre>
        </div>
  </li>
    </ol>

 <div class="note">
      <div class="notetitle">Note:</div>
 <p>The utilities gacutil and regasm are typically found in
 <span class="computeroutput">%WINDIR%\Microsoft.NET\Framework\&lt;version&gt;</span>
 e.g. <span class="computeroutput">C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705.288</span>.</p>
 </div>

 <p>Failure to register the components successfully as described will generate
 &quot;Virtuoso failed to initialize&quot; messages.  The Virtuoso installer, however, should
 automatically register the components for you.</p>

 <p>Private assemblies must be deployed within the directory of the
 containing application and are found during runtime through a process called
 probing - a mapping from an assembly&#39;s identity to a file on disk that contains
 the manifest. </p>

 <p>By default, probing for private assemblies is done from the root directory
 (application base) of the calling application (Virtuoso in this case) and the subdirectories that
 follow naming conventions based on assembly name and culture.  You can
 customize this behavior by specifying a privatePath in your application&#39;s
 configuration file. The privatePath is a semi-colon delimited list of directories
 that the common language runtime will search for private assemblies.  These
 directory names are relative to the application base - they cannot point outside
 the application base. The directories in the privatePath will be searched after
 the application base itself.  The following configuration file adds a bin
 directory to the assembly search path: </p>

<div>
      <pre class="programlisting">
&lt;configuration&gt;
    &lt;runtime&gt;
        &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
            &lt;probing privatePath=&quot;bin&quot;/&gt;
        &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
&lt;/configuration&gt;
</pre>
    </div>

 <p>Configuration files are called:
 <span class="computeroutput">&lt;application name&gt;.config</span>.  </p>
<br />

 <a name="rthclrdotnettest" />
    <h3>16.2.2. Testing the Virtuoso .NET Runtime Environment</h3>
 <p>To test that you have successfully started the Virtuoso server with
 .NET CLR runtime support make a simple library, import the contained class
 into Virtuoso and call it.</p>

 <p>Using an text editor create a C# source file in the server
 root directory called sanity.cs, with the following contents:</p>

 <div>
      <pre class="programlisting">
using System;

public class sanity
{
    public static string test(string  name) {
       return &quot;Hello &quot;+ name + &quot;, from Virtuoso&quot;;
    }
}
</pre>
    </div>
 <p>This sample needs to be compiled into bytecode assembly before it can
 be used.  Use a command prompt that is suitable set up to find .NET
 utilities in its path, the .NET Framework SDK installation provides a
 shortcut in the Start menu to a command prompt that is preconfigured.
 From the command prompt change directory to the Virtuoso server root
 containing the C# source file.</p>

 <div>
      <pre class="programlisting">
C:\Program Files\OpenLink\Virtuoso 3.0\bin&gt;csc /target:library sanity.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
</pre>
    </div>

 <p>Now this library must be introduce to the Virtuoso Server.  Using ISQL
 use the following commands to test the CLR:</p>

 <div>
      <pre class="programlisting">
C:\Program Files\OpenLink\Virtuoso 3.0\bin&gt;isql 1112
Connected to OpenLink Virtuoso
Driver: 03.00.2315 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL&gt; DB..import_clr (vector (&#39;sanity&#39;), vector (&#39;sanity&#39;));

Done. -- 300 msec.
SQL&gt; select sanity::test(&#39;Rob&#39;);
callret
VARCHAR
______________________________________________

Hello Rob, from Virtuoso

1 Rows. -- 60 msec.
</pre>
    </div>

 <p>Congratulations, you have proven that your Virtuoso server
 can run .NET classes.</p>

 <div class="tip">
      <div class="tiptitle">See Also:</div>
 <p>The Virtuoso Tutorials, which are installed with the Demo Virtuoso
 Server (port 1112), contains numerous samples further demonstrating the use
 of the CLR, .NET and Virtuoso.</p>
    </div>

  <div class="tip">
      <div class="tiptitle">See Also:</div>
    <p>The <a href="createassembly.html">Create Assembly</a> Syntax</p>
    <p>The External Hosted <a href="createassembly.html">Create PROCEDURE</a> Syntax</p>
    </div>

 <br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="rthactivation.html" title="Runtime Environments">Previous</a>
          <br />Runtime Environments</td>
     <td align="center" width="34%">
          <a href="runtimehosting.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="rthclrmono.html" title="CLR &amp; Mono">Next</a>
          <br />CLR &amp; Mono</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>