Lasse Edsvik said:
Sam,
trying to build a simple COM app that i'll use in regular ASP-pages
/Lasse
Now I'm confused. So far it looked like you were trying to create a Serviced Component.
Now it sounds like you are trying to build a COM library for a scripted environment.
COM+ (and hence enterprise services) evolved from MTS, not COM (it simply uses COM).
Are you talking about ASP or ASP.NET? If you are talking about ASP.NET then a serviced component
can be used but so can any .NET "component". What features of the enterprise services
environment do you want to use?
Are you talking about old style ASP? Are trying to expose a .NET assembly to COM?
Then you may find the following interesting:
NET Framework Developer's Guide: Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/d.../cpconexposingnetframeworkcomponentstocom.asp
NET Framework Developer's Guide: Packaging an Assembly for COM
http://msdn.microsoft.com/library/d...cpguide/html/cpconpackagingassemblyforcom.asp
++ From: Alex K. Angelopoulos \(MVP\) (
[email protected])
++ Subject: Building WSH-usable .NET components from the redistributables, revisited
++ Newsgroups: microsoft.public.dotnet.scripting, microsoft.public.scripting.vbscript,
++ microsoft.public.scripting.wsh, microsoft.public.windows.server.scripting,
microsoft.public.scripting.jscript
++ Date: 2003-03-14 18:51:04 PST
++
++ [due to potential interest, cross-posted to microsoft.public.dotnet.scripting,
++ microsoft.public.scripting.vbscript, microsoft.public.scripting.wsh,
++ microsoft.public.windows.server.scripting, microsoft.public.scripting.jscript.
++ FOLLOWUP set to .wsh only]
++
++ Several days ago I made a couple of posts about building WSH (actually generic
++ COM) scriptable .NET components using the compilers built into the
++ redistributable. This is a followup detailing a somewhat cleaner method for
++ doing this. It will work with the C#, VB.NET, and JScript.NET compilers
++ currently.
++
++ The process involves compilation of a simple class file, then registering its
++ codebase. This means there is minimal name protection, so be certain to use a
++ long, unique class name!! The lack of strong naming means this is best targeted
++ at on-the-fly creation of "anonymous" COM classes which will be removed after
++ use; in fact, as I try to generalize the technique, it will be best to include
++ strong naming as a feature.
++
++ In any case, below is a generic batch file for creating the DLLs, followed by
++ brief demos in each of the 3 compilers mentioned. Comments welcome; followups
++ are set to microsoft.public.scripting.wsh.
++
++ ======================================================
++
++ 1. Compilation into a COM-Callable Library
++
++ There are two simple steps: compile to a library, and then register the
++ codebase. The batch file shown below will do this given a source file name as
++ an argument; it determines which compiler to call based on the source file's
++ extension. The compiled DLL will have the same base name as the source file.
++
++ @echo off
++ :: generic .NET library compiler script
++ :: get the extension into %ext%
++ set srcfile=%1
++ set ext=%srcfile:~-2%
++
++ :: get the basename into %basename%
++ CALL SET basename=%srcfile:~0,-3%%
++ echo basename is %basename%
++
++ :: set the correct compiler
++ set exc=%ext%c
++
++ %exc% /nologo /t:library %basename%.%ext%
++ regasm /nologo /codebase %basename%.dll
++
++ 2. Run A Script Calling The Library.
++
++ If the class is named "thisismyclass" and it exposes a public function
++ "testfunction", you can run it from VBScript like this:
++
++ set cls = CreateObject("thisismyclass")
++ rtn = cls.testfunction
++
++
++ Demo classfile sources and VBScript demos are included below for the
++ Jscript.NET, C#, and VB.NET.
++
++
++ %---------- Test Jscript.NET Class File ----------
++ class testcompiledjscriptnet
++ {
++ public function testreturn()
++ {
++ // display the number of commandline items
++ return("this is a string returned from a Jscript.Net library.");
++ }
++ }
++ %---------- VBScript to test Jscript.NET Library ----------
++ set js = CreateObject("testcompiledjscriptnet")
++ wscript.echo js.testreturn
++
++
++
++ %---------- Test C# Class File ----------
++ public class testcompiledcsharpnet
++ {
++ public string testreturn()
++ {
++ return("this is a string returned from a C# library.");
++ }
++ }
++
++
++ %---------- VBScript to test C# Library ----------
++ set cs = CreateObject("testcompiledcsharpnet")
++ wscript.echo cs.testreturn
++
++ %---------- Test VB.NET Class File ----------
++ ' Test
++ public class testcompiledvbnet
++ public function testreturn() as string
++ return("this is a string returned from a VB.Net library.")
++ end function
++ end class
++ %---------- VBScript to test VB.NET Library ----------
++ set vb = CreateObject("testcompiledvbnet")
++ wscript.echo vb.testreturn
++
++
++
++
++
++
++
++ --
++ Please respond in the newsgroup so everyone may benefit.
++
http://dev.remotenetworktechnology.com
++ (email requests for support contract information welcomed)
++ ----------
++ Subscribe to Microsoft's Security Bulletins:
++
http://www.microsoft.com/technet/security/bulletin/notify.asp