WTL DLL
场景:wtl dll exception解决办法
wtl dll exception
The start reason is that I want to change a WTL exe project to dll project so that I could use it as plugin in another project. Those code worked well in the exe, but got exception in the DLL. I tracked it down, initialization is fine, when it goes to the
CWindowImpl::create->
T::GetWndClassInfo().Register(&m_pfnSuperWindowProc)->
... if (FAILED(lock.Lock())) then
Collapse | Copy Code
inline HRESULT CComCritSecLock< TLock >::Lock() throw()
{ HRESULT hr;
ATLASSERT( !m_bLocked );
hr = m_cs.Lock();//exception caught
if( FAILED( hr ) )
{ return( hr ); }
m_bLocked = true;
return( S_OK ); }
------解决方案--------------------
你可以把这个替换为EnterCriticalSection等。还有可以看看下面的
CComCritSecLock::Lock
See Also Send Feedback
Call this method to lock the critical section object.
HRESULT Lock( ) throw( );
Return Value
Returns S_OK if the object has successfully been locked, or an error HRESULT on failure.
Remarks
If the object is already locked, an ASSERT error will occur in debug builds.
------解决方案--------------------
没看出来执行到哪条语句报异常
wtl dll exception
The start reason is that I want to change a WTL exe project to dll project so that I could use it as plugin in another project. Those code worked well in the exe, but got exception in the DLL. I tracked it down, initialization is fine, when it goes to the
CWindowImpl::create->
T::GetWndClassInfo().Register(&m_pfnSuperWindowProc)->
... if (FAILED(lock.Lock())) then
Collapse | Copy Code
inline HRESULT CComCritSecLock< TLock >::Lock() throw()
{ HRESULT hr;
ATLASSERT( !m_bLocked );
hr = m_cs.Lock();//exception caught
if( FAILED( hr ) )
{ return( hr ); }
m_bLocked = true;
return( S_OK ); }
initialization
exception
exe
dll
------解决方案--------------------
你可以把这个替换为EnterCriticalSection等。还有可以看看下面的
CComCritSecLock::Lock
See Also Send Feedback
Call this method to lock the critical section object.
HRESULT Lock( ) throw( );
Return Value
Returns S_OK if the object has successfully been locked, or an error HRESULT on failure.
Remarks
If the object is already locked, an ASSERT error will occur in debug builds.
------解决方案--------------------
没看出来执行到哪条语句报异常