Microsoft KB Archive/264526

= Snaoledb.dll Init Fails When the CoInitializeEx Multithreaded Function Is Used =

Article ID: 264526

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Host Integration Server 2000 Standard Edition
 * Microsoft SNA Server 4.0
 * Microsoft SNA Server 4.0 Service Pack 1
 * Microsoft SNA Server 4.0 Service Pack 2
 * Microsoft SNA Server 4.0 Service Pack 3
 * Microsoft OLE DB Provider for AS/400 and VSAM 4.0 SP2
 * Microsoft OLE DB Provider for AS/400 and VSAM 4.0 SP3

-



This article was previously published under Q264526



SYMPTOMS
If an application thread calls the CoInitializeEx(NULL, CO_MULTITHREADED) function on a Windows NT 4.0-based computer, the thread may receive the following error message when it attempts to initialize the OLE DB Provider for AS/400 and VSAM:

Initialization of the dynamic link library e:\program files\sna\system\snaoledb failed. The process is terminating abnormally.

This problem does not occur on Windows 2000-based computers, or if Apartment threading is requested.

NOTE: Even though the OLE DB Provider for AS/400 and VSAM only supports the Apartment-threading model (as documented in the SNA Server SDK online Help topic &quot;Programming Considerations Using the OLE DB Provider for AS/400 and VSAM&quot;), the application calling the thread must still be able to initialize the COM interface using the Multithreaded option.



CAUSE
The OLE DB Provider for AS/400 and VSAM is incorrectly calling OleInitialize, requiring the calling thread to request Apartment threading.



RESOLUTION
To resolve this problem, obtain the latest service pack for SNA Server 4.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

215838 How to Obtain the Latest SNA Server Version 4.0 Service Pack



WORKAROUND
If possible, initialize the thread using the Apartment-threading model:

Call CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)

-OR-

Call CoInitialize(NULL)



STATUS
Microsoft has confirmed that this is a problem in Microsoft SNA Server version 4.0, 4.0 SP1, 4.0 SP2 and 4.0 SP3.

This problem was first corrected in SNA Server 4.0 Service Pack 4.



MORE INFORMATION
The following sample program can be used to reproduce this problem. In this sample, the error message occurs when Initialize is called: int main {       HRESULT            hr                 = S_OK; IDataInitialize   *pIDataInitialize  = NULL; IDBInitialize     *pIDBInitialize    = NULL; LPOLESTR pwszFileName = SysAllocString (OLESTR(&quot;c:\\thor.udl&quot;));
 * 1) define DBINITCONSTANTS
 * 2) define INITGUID
 * 3) define _WIN32_DCOM
 * 4) include 
 * 5) include 
 * 6) include 
 * 7) include 
 * 8) include 
 * 9) include 
 * 10) include 

LPOLESTR ppwszInitializationString;

hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); assert (hr == S_OK); hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize,       reinterpret_cast(&pIDataInitialize));

hr = pIDataInitialize->LoadStringFromStorage(pwszFileName, &ppwszInitializationString);

hr = pIDataInitialize->GetDataSource(NULL,CLSCTX_INPROC_SERVER, ppwszInitializationString, IID_IDBInitialize, (IUnknown **)(&pIDBInitialize));

hr = pIDBInitialize->Initialize;

SysFreeString (pwszFileName); SysFreeString (ppwszInitializationString);

hr = pIDBInitialize->Release ; CoUninitialize;

return 0; } NOTE: When you build the project above, make sure to link with the multithreaded Microsoft C Runtime Library and Msdasc.lib.

Additional query words: HIS 2000

Keywords: kbbug kbfix kbqfe kbsna400presp4fix kbsna400sp4fix KB264526

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.