-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: zubinraj76
Message 4 in Discussion
More on entry points...
An
entry point is the first method that the runtime will call after loading that
assembly.
This
entry point is defined and is stored in a field called 'EntryPointToken' in the
header section of the assembly (the header exists for both exe and dll) during
the IL is generated.
In case of exe
For an
exe, this field has to be set to a valid method, that's why Visual Studio will
not let you compile before defining a valid entry point method. The CLS
specifies that this method should be static, should return either an
'unsigned int' or 'void' as its return type and it should take
parameters of at least a 'string' or 'string[]'.
I hope
you should be familiar with the Main method in exe which is usually declared as
follows :
public
static void Main(string[] args)
{
}
In case of dll
In
case of a dll, there are 2 cases :
1. For
a dll which is a pure IL (i.e no native code is present), no entry point is
needed and the field 'EntryPointToken' in the header should be set by the
compiler as '0'.
2. For
a dll which has some native code (dll's generated by Managed C++), an entry
point has to be defined which will take the following format
:
bool
DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
}
DllMain is required as this is first method called when called from the
unmanaged scenario. This is used for initialization during dll
load.
The
DllMain() method has to be implemented as a P/Invoke so that it can be called
from unmanaged code also.
So for
dll's for which DllMain() is present, this becomes the entry point.
The address of this method will be set in the field 'EntryPointToken' in the
header by the compiler during the IL is generated.
Prasad, hope you can solve your problem on your own
now..
Don't
hesitate to mail if you have more doubts.
Regards,
Zubin.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]