i have a component by
VB.Net. but i don't know hor to register it with windows, let windows(or .Net framewaork) know that it's belongs to .Net, and any application can make a reference to that component.
After i create a storng name,i use the command "regsvcs" from the .Net Command Prompt. My component appears in the tab COM of .NET(when add referrence/Com) but i can't use it.But if i add reference to the component by giving the path direcly to the .dll file ,everything works well
the flowwing code is what i did, i need help to continue work on this thing(COM+ Component). so someone plz help me. i'm using windows 2000 professional, .net 2003
//this is the component code
Imports System.EnterpriseServices
Imports System.Reflection
<Assembly: AssemblyKeyFileAttribute("BankComponent.snk")>
Public Class BankComponent
Inherits ServicedComponent
Public Sub Interest(ByVal pname As String, ByVal pamount As Int16, ByVal pyear As Int16)
Dim samount As String
Dim msgstring As String
Dim totalamount As Int16
If (pyear = 5) Then
totalamount = pamount + (pyear * (pamount * 12 / 100))
samount = Convert.ToString(totalamount)
msgstring = pname + ":" + samount
MsgBox(msgstring)
ElseIf (pyear = 3) Then
totalamount = pamount + (pyear * (pamount * 10 / 100))
samount = Convert.ToString(totalamount)
msgstring = pname + ":" + samount
MsgBox(msgstring)
ElseIf (pyear = 2) Then
Int(totalamount = pamount + (pyear * (pamount * 8 / 100)))
samount = Convert.ToString(totalamount)
msgstring = pname + ":" + samount
MsgBox(msgstring)
Else
MsgBox("not a valid Sheme")
End If
End Sub
End Class
//this is the testProgram
Imports BankComponent
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 184)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 56)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(112, 112)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 112)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(88, 23)
Me.Label1.TabIndex = 2
Me.Label1.Text = "years"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 32)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 3
Me.Label2.Text = "Name"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 72)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 4
Me.Label3.Text = "Amount"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(112, 80)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(112, 32)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim obj As New BankComponent.BankComponent
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim localyear As Int16
Dim localamount As Int16
Dim localname As String
localyear = CInt(Me.TextBox1.Text)
localamount = CInt(Me.TextBox2.Text)
localname = Me.TextBox3.Text
obj.Interest(localname, localamount, localyear)
End Sub
End Class