all groups > dotnet component services > july 2003 >
You're in the

dotnet component services

group:

Is there Sample Code for creating a Object for use with IIS and ASP (Not ASp.Net)?


Is there Sample Code for creating a Object for use with IIS and ASP (Not ASp.Net)? Scott Townsend
7/22/2003 2:22:12 PM
dotnet component services:
I'm trying to write a COM Object in VB .NET and not having the best of luck.



I'm not 100% sure that I have the Code writen properly to expose the methods
in my object or if I'm just not registering the dll properly on the Target
machine.



I've included the Code for the Object below. Does it Look fine?



I then register it on the Target machine with the following:

regasm comMyCom.dll /tlb:comMyCom.tlb /codebase
gacutil /i comMyCom.dll
installutil comMyCom.dll

regsvcs comMyCom.dll

I've tried the above separately in different order nothing seems to work.
When I look at the Object in the Component Services Snapin. I do not see the
send method for the _comMyCom Interface. I see it for the IcomMyCom
interface.



What Gives?



Any tips would be appreciated!



Scott<-



----------------------------------------------------------------------------

AssemblyInfo.vb

----------------------------------------------------------------------------

Imports System

Imports System.Reflection

Imports System.Runtime.InteropServices

Imports System.EnterpriseServices

Imports System.EnterpriseServices.ActivationOption

Imports System.EnterpriseServices.AccessChecksLevelOption



' General Information about an assembly is controlled through the following

' set of attributes. Change these attribute values to modify the information

' associated with an assembly.

' Review the values of the assembly attributes

<Assembly: AssemblyTitle("ComMyCom")>

<Assembly: AssemblyDescription("")>

<Assembly: AssemblyCompany("E&M Electric, Inc.")>

<Assembly: AssemblyProduct("")>

<Assembly: AssemblyCopyright("2003")>

<Assembly: AssemblyTrademark("")>

<Assembly: CLSCompliant(True)>

'The following GUID is for the ID of the typelib if this project is exposed
to COM

<Assembly: Guid("8A4F863A-1CD4-4E8E-942C-912EF1B1D975")>

'<Assembly: ApplicationAccessControl(True)>

<Assembly: ApplicationAccessControl(True)>

#Region "COM+ Registration details "

'Supply the COM+ application name

<Assembly: ApplicationNameAttribute("ComMyCom")>

<Assembly: ApplicationActivation(ActivationOption.Server)>

'Supply a strong-name assembly

<Assembly: AssemblyKeyFileAttribute("..\\..\\comMyCom.snk")>

#End Region





' Version information for an assembly consists of the following four values:

'

' Major Version

' Minor Version

' Build Number

' Revision

'

' You can specify all the values or you can default the Build and Revision
Numbers

' by using the '*' as shown below:

<Assembly: AssemblyVersion("1.0.*")>





----------------------------------------------------------------------------

comMyCom.vb

----------------------------------------------------------------------------

Option Explicit On

Option Strict On

Imports System

Imports System.web.mail

Imports System.EnterpriseServices

Imports System.EnterpriseServices.ActivationOption

Imports System.EnterpriseServices.EventTrackingEnabledAttribute

Imports System.Reflection

Imports System.Runtime.InteropServices

Imports System.Runtime.InteropServices.ClassInterfaceType



Public Interface IcomMyCom

Function Send(ByVal strEmailAddress As String, ByVal strEmailServer As
String) As Boolean

End Interface



' I've tied the three Attributes with all the same results....

'<ComClass(comMyCom.ClassId, comMyCom.InterfaceId, comMyCom.EventsId)> _

'Public Class comMyCom

'<ClassInterfaceAttribute(ClassInterfaceType.AutoDual)> _

'Public Class comMyCom

<TransactionAttribute(TransactionOption.Required)> _

Public Class comMyCom

Inherits EnterpriseServices.ServicedComponent

Implements IcomMyCom

'Inherits ServicedComponent

' Use the Region directive to define a section named COM Guids.

#Region "COM GUIDs"

' These GUIDs provide the COM identity for this class

' and its COM interfaces. You can generate

' these guids using guidgen.exe

Public Const ClassId As String = "6983A5C3-6E8A-46d9-90B3-4426BE69588C"

Public Const InterfaceId As String = "5203E497-075F-4f6f-9A25-B697A0C38A6D"

Public Const EventsId As String = "F871F568-5407-4f34-BF00-1A2BDAEC03F1"

#End Region



Public Sub New()

MyBase.New()

End Sub



Public Function Send(ByVal strEmailAddress As String, ByVal strEmailServer
As String) As Boolean Implements IcomMyCom.Send

Send = True

End Function

End Class



Re: Is there Sample Code for creating a Object for use with IIS and ASP (Not ASp.Net)? Kumar Gaurav Khanna [.NET MVP]
7/26/2003 9:29:29 PM
Hi!

Once you create the component, install it into a COM+ application using the
COM+ MMC in Administrative Tools. Next, export the proxy for the application
and install it in the relevant client systems. Add a reference to this proxy
(Add Reference->COM components) in your .NET application.

Regards,
Gaurav Khanna

--
----------------------------------------------------------------------------
----------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
----------------------------------------------------------------------------
----------

[quoted text, click to view]

Re: Is there Sample Code for creating a Object for use with IIS and ASP (Not ASp.Net)? Mike Dice [MSFT]
7/30/2003 7:34:33 AM
Scott,
Please have a look at this article in the .Net SDK docs too about exposing
..Net objects to COM. That is what you are really doing.

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp?frame=true

Mike

[quoted text, click to view]

AddThis Social Bookmark Button