Entry point not defined
Hi people.
Im using source code from a microsoft self paced book(70320) to create and consume a component (com+)
when I try to build the project I get the following message:
Program 'C:\EC70320\BankAccounts\obj\Debug\BankAccounts.exe' does not have an entry point defined
I've created the snk file using the Sn.exe tool
and here is the source code, im not sure where im going wrong
using
System;using
System.Reflection;using
System.Data;using
System.Data.SqlClient;using
System.EnterpriseServices;using
System.Collections;using
System.Windows.Forms;[assembly: AssemblyKeyFile("..\\..\\MyKey.snk")]
// Delete the AssemblyKeyFile from the AssembleInfo.cs file
// which VS creats automatically
namespace
BankAccounts{
[Transaction(TransactionOption.Required), ObjectPooling(MinPoolSize =1,
MaxPoolSize =5),
JustInTimeActivation(
true), SecurityRole("Authorized Users",false),ConstructionEnabled(Default =
"server=localhost; intergrated security=sspi; database=Northwind")]
publicclass Account : ServicedComponent{
// member that stores connection string valueprivate String connectionString;public Account(){
//// TODO: Add constructor logic here//}
protectedoverridevoid Construct(string constructString){
// called after constructor// connectionString can be configured from the activation tab//in the properties window of the account componentconnectionString = constructString;
}
//METHOD TO CREATE AN ACCOUNT//AUTOCOMPLETE ENSURES THAT TRANSACTION IS COMMITED WHEN THE//METHOD RETURNS NORMALLY, ELSE THE TRANSACTION IS ROLLED BACK[AutoComplete()]
publicvoid createAccount(int id ,int amt){
//create connection to the databaseSqlConnection conn =
new SqlConnection(connectionString);//SQL statement to be executedstring stmt = "insert into accounts values(" + id + "," +amt + ")";
//SQL command to be executed over the connection//SQL command eccapsulates the SQL statementSqlCommand command =
new SqlCommand(stmt, conn);//open the connection before executing the commandconn.Open();
//execut the commandcommand.ExecuteNonQuery();
//close the connectionconn.Close();
}
//Method to transfer the amount from one account to another//AutoComplete ensures that the transaction is commited when the//method returns normally, else the transaction is rolled back[AutoComplete()]
publicvoid transferMoney(int fromAccount,int toAccount,int amt){
//create a connection to the database serverSqlConnection conn =
new SqlConnection(connectionString);// Update balance in the account from which the balance is transferredstring stmt = "update accounts set bal=bal-" + amt +" where id =" + fromAccount;
SqlCommand command =
new SqlCommand(stmt, conn);conn.Open();
command.ExecuteNonQuery();
//update the balance in the account to which the balace is//transferedstmt = "update accounts set bal=bal+" + amt +
"where id =" + toAccount;
command =
new SqlCommand(stmt, conn);command.ExecuteNonQuery();
//retrieve the new balances in the accounts involved in the//transferint fromBal = getBal(fromAccount);int toBal = getBal(toAccount);//Ensure that fromBal is more than or equal to 5000//and that toBal is less than or equal to <=25000if (fromBal >= 5000 && toBal <= 25000){
MessageBox.Show("Money Transferred Succesfully!");
}
else{
//if any of the condition is not fulfilled// close the connection and throw an exceptionconn.Close();
thrownew Exception("Can not transfer money!");//<<this aborts the trabsaction}
}
//method to get balace in accountpublicint getBal(int id ){
//connect to the database serverSqlConnection conn =
new SqlConnection(connectionString);string stmt = "select bal from accounts where id=" + id;//create command object to execute over the serverSqlCommand Command =
new SqlCommand(stmt, conn);//open connectionconn.Open();
//execute a query that returns only 1 scalar valueint bal=(int)Command.ExecuteScalar();conn.Close();
return bal;}
//method to get all the ids of all accounts in the accounts tablepublic ArrayList getAccountIds(){
SqlConnection conn =
new SqlConnection(connectionString);string stmt = "select id from accounts ";SqlCommand Command =
new SqlCommand(stmt, conn);conn.Open();
//ExecuteReader method returns a SQLDataReader// that allows you to sequentially read data from the tableSqlDataReader dr = Command.ExecuteReader();
ArrayList ids=
new ArrayList();//Add values to the ArrayList objectwhile (dr.Read()){
ids.Add(dr.GetValue(0));
}
conn.Close();
return ids;}
}
}

