I have created an ATL COM DLL using the New Project Wizzard in Microsoft Visual Studio 6. Called Webcounter.
I have added a Simple ATL Object called Counter and also added two functions called Increment and GetCount.
When I comile this Project as a "Debug Release" it compiles fine but, when i try to compile it as any sort of "Release" version the compiler gives me this error.
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinDependency/WebCo
unter.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Howvever if i add -
void main()
{
}
to webcounter.cpp it compiles fine, why is this it already has a DllMain Why do i need to add void main to make it compile and why does the wizzard not do this, or should i not be doing this and is the problem elsewhere.
NOW THE MAIN PROBLEM?
=====================
I am Calling this ATL COM DLL from an Active Server Page (ASP) on my webserver using -
Set myObj = Server.CreateObject("Webco
unter.Coun
ter")
Which works fine, this object then appears to work fine for several consecutive calls until however it crashes the webserver (IIS4 on NT4 SP6a). Why does it crash, am I leaking memory here or are any of the Windows calls i make NOT threadsafe, as I understand that calls from a Mutiluser COM DLL need to threadsafe ? (Dont they? Im sure ive been told this?)
If anyone wants the full source code so they can
understand my problem look here
http://www.dynamic-server.net/atlwebcounter-src.zipElse listed below is the source code of my two functions.
STDMETHODIMP CCounter::Increment(BSTR strPage, BSTR strFilename, BOOL *bResult)
{
_bstr_t bstrPage(strPage, FALSE);
_bstr_t bstrFilename(strFilename, FALSE);
//Open Count
int iCount = GetPrivateProfileInt("User
s", (char*)bstrPage, -1, (char*)bstrFilename);
if(iCount <= 0)
{
//File does not exist or could not find key entry
iCount = 1;
}
else
{
//Increment Count
iCount++;
}
//Save Count
char cCount[10] = "\0";
itoa(iCount, cCount, 10);
if(WritePrivateProfileStri
ng("Users"
, (char*)bstrPage, cCount, (char*)bstrFilename) == 0)
{
*bResult = FALSE;
}
else
{
*bResult = TRUE;
}
return S_OK;
}
STDMETHODIMP CCounter::GetCount(BSTR strPage, BSTR strFilename, int *iCount)
{
// TODO: Add your implementation code here
_bstr_t bstrPage(strPage, FALSE);
_bstr_t bstrFilename(strFilename, FALSE);
//Open Count
*iCount = GetPrivateProfileInt("User
s", (char*)bstrPage, -1, (char*)bstrFilename);
return S_OK;
}