I am stuck up with this error for a very long time... Can anyone please help me out...
I have created a strong name key file and run the gacutil to attach the dll to the assembly.. When i try to run the regsvcs bankaccounts.dll i get the following error...
Invalid ServicedComponent-derived classes were
found in the assembly.
(Classes must be public, concrete, have a public
default constructor, and meet all other ComVisibility
requirements)
BankAccounts.Account: Unspecified error
Here is the code which i am trying to register.. Please help!!!
Imports System.EnterpriseServices
Imports system
Imports System.Reflection
Imports System.Data
Imports System.Data.SqlClient
'Imports System.Runtime.InteropServices
<Assembly: ApplicationName("BankAccounts")>
<Assembly: AssemblyKeyFile("C:\Documents and Settings\280119\My Documents\Visual Studio 2005\Projects\BankAccounts\BankAccounts\Key.snk")>
<Transaction(TransactionOption.Required), ObjectPooling(minpoolsize:=1, maxpoolsize:=5), JustInTimeActivation(True), SecurityRole("Authorized Users", False), ConstructionEnabled([Default]:="server=localhost; integrated security=sspi; database=Northwind")> _
Public Class Account
Inherits ServicedComponent
Private connectionstring As String
Protected Overrides Sub Construct(ByVal constructstring As String)
connectionstring = constructstring
End Sub
<AutoComplete()> Public Sub createaccount(ByVal id As Integer, ByVal amt As Integer)
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " inserts into accounts values (" & id & "," & amt & ")"
Dim command As New SqlCommand(stmt, conn)
conn.Open()
command.ExecuteNonQuery()
conn.Close()
End Sub
<AutoComplete()> Public Sub transfermoney(ByVal fromaccount As Integer, ByVal toaccount As Integer, ByVal amt As Integer)
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " update accounts set bal = bal-" & amt & "where id =" & fromaccount
Dim command As New SqlCommand(stmt, conn)
conn.Open()
command.ExecuteNonQuery()
stmt = " update account set bal = bal+" & amt & "where is =" & toaccount
command = New SqlCommand(stmt, conn)
command.ExecuteNonQuery()
Dim frombal As Integer = getbal(fromaccount)
Dim tobal As Integer = getbal(toaccount)
If frombal >= 5000 And tobal <= 25000 Then
MsgBox("Money trnasferred Successfully")
conn.Close()
Else
conn.Close()
MsgBox("Cannot transfer Money!!!")
End If
End Sub
Public Function getbal(ByVal id As Integer) As Integer
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " select bal from accounts where = " & id
Dim command As New SqlCommand(stmt, conn)
conn.Open()
getbal = CType(command.ExecuteScalar(), Integer)
conn.Close()
End Function
Public Function getaccountids() As ArrayList
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = "select id from accounts"
Dim command As New SqlCommand(stmt, conn)
conn.Open()
Dim dr As SqlClient.SqlDataReader = command.ExecuteReader
Dim ids As New ArrayList()
While dr.Read
ids.Add(dr.GetValue(0))
End While
conn.Close()
Return ids
End Function
End Class
I have created a strong name key file and run the gacutil to attach the dll to the assembly.. When i try to run the regsvcs bankaccounts.dll i get the following error...
Invalid ServicedComponent-derived classes were
found in the assembly.
(Classes must be public, concrete, have a public
default constructor, and meet all other ComVisibility
requirements)
BankAccounts.Account: Unspecified error
Here is the code which i am trying to register.. Please help!!!
Imports System.EnterpriseServices
Imports system
Imports System.Reflection
Imports System.Data
Imports System.Data.SqlClient
'Imports System.Runtime.InteropServices
<Assembly: ApplicationName("BankAccounts")>
<Assembly: AssemblyKeyFile("C:\Documents and Settings\280119\My Documents\Visual Studio 2005\Projects\BankAccounts\BankAccounts\Key.snk")>
<Transaction(TransactionOption.Required), ObjectPooling(minpoolsize:=1, maxpoolsize:=5), JustInTimeActivation(True), SecurityRole("Authorized Users", False), ConstructionEnabled([Default]:="server=localhost; integrated security=sspi; database=Northwind")> _
Public Class Account
Inherits ServicedComponent
Private connectionstring As String
Protected Overrides Sub Construct(ByVal constructstring As String)
connectionstring = constructstring
End Sub
<AutoComplete()> Public Sub createaccount(ByVal id As Integer, ByVal amt As Integer)
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " inserts into accounts values (" & id & "," & amt & ")"
Dim command As New SqlCommand(stmt, conn)
conn.Open()
command.ExecuteNonQuery()
conn.Close()
End Sub
<AutoComplete()> Public Sub transfermoney(ByVal fromaccount As Integer, ByVal toaccount As Integer, ByVal amt As Integer)
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " update accounts set bal = bal-" & amt & "where id =" & fromaccount
Dim command As New SqlCommand(stmt, conn)
conn.Open()
command.ExecuteNonQuery()
stmt = " update account set bal = bal+" & amt & "where is =" & toaccount
command = New SqlCommand(stmt, conn)
command.ExecuteNonQuery()
Dim frombal As Integer = getbal(fromaccount)
Dim tobal As Integer = getbal(toaccount)
If frombal >= 5000 And tobal <= 25000 Then
MsgBox("Money trnasferred Successfully")
conn.Close()
Else
conn.Close()
MsgBox("Cannot transfer Money!!!")
End If
End Sub
Public Function getbal(ByVal id As Integer) As Integer
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = " select bal from accounts where = " & id
Dim command As New SqlCommand(stmt, conn)
conn.Open()
getbal = CType(command.ExecuteScalar(), Integer)
conn.Close()
End Function
Public Function getaccountids() As ArrayList
Dim conn As New SqlConnection(connectionstring)
Dim stmt As String = "select id from accounts"
Dim command As New SqlCommand(stmt, conn)
conn.Open()
Dim dr As SqlClient.SqlDataReader = command.ExecuteReader
Dim ids As New ArrayList()
While dr.Read
ids.Add(dr.GetValue(0))
End While
conn.Close()
Return ids
End Function
End Class