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 value

private 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 component

connectionString = 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 database

SqlConnection conn =new SqlConnection(connectionString);

//SQL statement to be executed

string stmt = "insert into accounts values(" + id + "," +

amt + ")";

//SQL command to be executed over the connection

//SQL command eccapsulates the SQL statement

SqlCommand command =new SqlCommand(stmt, conn);

//open the connection before executing the command

conn.Open();

//execut the command

command.ExecuteNonQuery();

//close the connection

conn.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 server

SqlConnection conn =new SqlConnection(connectionString);

// Update balance in the account from which the balance is transferred

string 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

//transfered

stmt = "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

//transfer

int 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 <=25000

if (fromBal >= 5000 && toBal <= 25000)

{

MessageBox.Show("Money Transferred Succesfully!");

}

else

{

//if any of the condition is not fulfilled

// close the connection and throw an exception

conn.Close();

thrownew Exception("Can not transfer money!");//<<this aborts the trabsaction

}

}

//method to get balace in account

publicint getBal(int id )

{

//connect to the database server

SqlConnection conn =new SqlConnection(connectionString);

string stmt = "select bal from accounts where id=" + id;

//create command object to execute over the server

SqlCommand Command =new SqlCommand(stmt, conn);

//open connection

conn.Open();

//execute a query that returns only 1 scalar value

int bal=(int)Command.ExecuteScalar();

conn.Close();

return bal;

}

//method to get all the ids of all accounts in the accounts table

public 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 table

SqlDataReader dr = Command.ExecuteReader();

ArrayList ids=new ArrayList();

//Add values to the ArrayList object

while (dr.Read())

{

ids.Add(dr.GetValue(0));

}

conn.Close();

return ids;

}

}

}

[10989 byte] By [airwalker2000] at [2008-2-22]
# 1

I sorted out the entry point issue, but now when I build the project im not getting a .dll file created. Does anybody know how I can resolve this.

Thanks in advance..

airwalker2000 at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 2

Are you using Visual Studio to build your project?

What book are you referring to?

FlorinLazar-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 3

What .dll are you expecting to be created? I can posit a guess. You added a static main entry point to an existing or new class in the same project as the ServicedComponent to resolve the first issue. You built the project and are now looking for a .dll that contains the ServicedComponent so you can register it? If all the code is in the same project it will indeed just build the executable.

If this is the case, I believe you should actually register the .exe in place of a .dll. You could also create a seperate project with the main entry point that includes a reference to the original project with the ServicedComponent. You should make sure that the original project is set to build a dll as opposed to a console/window application.

There is also an auto-registration that should be done if you just run your .exe without having registered the ServicedComponent.

hth,
Miguel

MiguelGasca-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...

Software Development for Windows Vista

Site Classified