Click here to Skip to main content
15,900,110 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: And Add-in for MS Outlook Pin
hybride17-Feb-06 1:08
hybride17-Feb-06 1:08 
QuestionAdd-in for MS Outlook Pin
hybride25-Jan-06 22:39
hybride25-Jan-06 22:39 
AnswerRe: Add-in for MS Outlook Pin
Ganesh_T16-Feb-06 23:18
Ganesh_T16-Feb-06 23:18 
AnswerRe: Add-in for MS Outlook Pin
hybride17-Feb-06 1:11
hybride17-Feb-06 1:11 
AnswerRe: Add-in for MS Outlook Pin
el_barri25-Sep-08 22:50
el_barri25-Sep-08 22:50 
QuestionEmbedding controls in Excel Pin
frogstomp25-Jan-06 0:13
frogstomp25-Jan-06 0:13 
QuestionHow to create a visual studio'ish prop ctrl? Pin
ioctl5124-Jan-06 2:55
ioctl5124-Jan-06 2:55 
QuestionATL COM with IIS6 Pin
MaX B.24-Jan-06 0:15
MaX B.24-Jan-06 0:15 
Hi, I've written (using C++ VS6) a very simple ATL COM used by asp pages. The
COM has a static global variable g_counter of long type; then the COM exposes
an Object Pluto, with a method "Increment_g_Counter" that increments the
global variable g_counter and a property get_G_Counter that retrieves the
value of g_counter.

The question is: why, using OS W2k3 and IIS6 (running in iis 5.0 isolation
mode), after a few minutes, if no clients call the asp page, the g_counter
values is 0?
IIS6 seems to unload the atl com dll (the ExitInstance Method of the
CTestasp_comApp is called) after a few minutes; I say "seems" because if I
try to copy the com dll, the system tells me "the source or the destination
file may be in use".
I think that this behavior is due to the garbage collector of IIS6.

This is the com sample code:
CComModule _Module;
static long g_counter = 0;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Pluto, CPluto)
END_OBJECT_MAP()

class CTestasp_comApp : public CWinApp
{
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestasp_comApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL

//{{AFX_MSG(CTestasp_comApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CTestasp_comApp, CWinApp)
//{{AFX_MSG_MAP(CTestasp_comApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CTestasp_comApp theApp;

BOOL CTestasp_comApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_TESTASP_COMLib);
FILE *fptrace = fopen( "f:\\giffile\\asptrace.txt", "a" );

if ( fptrace != NULL )
{
fprintf( fptrace, "InitInstance g_counter=%d\n", g_counter );
fclose( fptrace );
}

return CWinApp::InitInstance();
}

int CTestasp_comApp::ExitInstance()
{
FILE *fptrace = fopen( "f:\\giffile\\asptrace.txt", "a" );

if ( fptrace != NULL )
{
fprintf( fptrace, "ExitInstance g_counter=%d\n", g_counter );
fclose( fptrace );
}
_Module.Term();
return CWinApp::ExitInstance();
}
This the object code

class ATL_NO_VTABLE CPluto :
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<cpluto, &clsid_pluto="">,
public IDispatchImpl<ipluto, &iid_ipluto,="" &libid_testasp_comlib="">
{
public :
CPluto()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_PLUTO)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CPluto)
COM_INTERFACE_ENTRY(IPluto)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

// IPluto
public:
STDMETHOD(get_G_Counter)(/*[out, retval]*/ long *pVal);
STDMETHOD(Increment_g_Counter)(/*[out,retval]*/int *ok);
};

#endif //__PLUTO_H_

.cpp
STDMETHODIMP CPluto::Increment_g_Counter(int *ok)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
CSingleLock lock( &gLockManager, TRUE );
g_counter++;
lock.Unlock();
return S_OK;
}

STDMETHODIMP CPluto::get_G_Counter(long *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = g_counter;
return S_OK;
}

This is the asp code

Dim value
Dim counter_object
Set counter_object = Server.CreateObject( "testasp_com.Pluto")
counter_object.Increment_g_Counter
value = counter_object.G_Counter
Response.Write "Value is" & value & "
"
Set counter_object = Nothing

I need a behavior like iis5 that keeps COM global variables alive until an
iisreset command is sent.

Thanks for any help.

Max

Confused | :confused:

Massimo B.
AnswerRe: ATL COM with IIS6 Pin
Michael Dunn24-Jan-06 7:23
sitebuilderMichael Dunn24-Jan-06 7:23 
GeneralRe: ATL COM with IIS6 Pin
MaX B.24-Jan-06 21:55
MaX B.24-Jan-06 21:55 
GeneralRe: ATL COM with IIS6 Pin
Igor Vigdorchik27-Jan-06 16:17
Igor Vigdorchik27-Jan-06 16:17 
QuestionCManualAccessor - No rows if using properties Pin
Guybrush23-Jan-06 9:05
Guybrush23-Jan-06 9:05 
AnswerRe: CManualAccessor - No rows if using properties Pin
Guybrush25-Jan-06 7:04
Guybrush25-Jan-06 7:04 
QuestionICopyHook Pin
ragavan23-Jan-06 3:00
ragavan23-Jan-06 3:00 
QuestionTransparent Static control ATL Pin
Anilkumar K V22-Jan-06 22:26
Anilkumar K V22-Jan-06 22:26 
AnswerRe: Transparent Static control ATL Pin
Stephen Hewitt22-Jan-06 23:17
Stephen Hewitt22-Jan-06 23:17 
GeneralRe: Transparent Static control ATL Pin
Anilkumar K V23-Jan-06 0:00
Anilkumar K V23-Jan-06 0:00 
GeneralRe: Transparent Static control ATL Pin
Stephen Hewitt23-Jan-06 0:10
Stephen Hewitt23-Jan-06 0:10 
GeneralRe: Transparent Static control ATL Pin
Anilkumar K V23-Jan-06 0:52
Anilkumar K V23-Jan-06 0:52 
GeneralRe: Transparent Static control ATL Pin
Stephen Hewitt23-Jan-06 1:36
Stephen Hewitt23-Jan-06 1:36 
GeneralRe: Transparent Static control ATL Pin
Anilkumar K V23-Jan-06 1:50
Anilkumar K V23-Jan-06 1:50 
GeneralRe: Transparent Static control ATL Pin
Stephen Hewitt23-Jan-06 1:58
Stephen Hewitt23-Jan-06 1:58 
GeneralRe: Transparent Static control ATL Pin
Anilkumar K V23-Jan-06 16:13
Anilkumar K V23-Jan-06 16:13 
GeneralRe: Transparent Static control ATL Pin
Stephen Hewitt23-Jan-06 16:17
Stephen Hewitt23-Jan-06 16:17 
GeneralRe: Transparent Static control ATL Pin
Anilkumar K V23-Jan-06 16:43
Anilkumar K V23-Jan-06 16:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.