Microsoft KB Archive/264526

From BetaArchive Wiki
Knowledge Base


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 "Programming Considerations Using the OLE DB Provider for AS/400 and VSAM"), 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:

#define DBINITCONSTANTS
#define INITGUID
#define _WIN32_DCOM
#include <windows.h>
#include <msdaguid.h>
#include <oledb.h>
#include <tchar.h>
#include <stdio.h>
#include <assert.h>
#include <msdasc.h>
int main ()
{
        HRESULT            hr                 = S_OK;
    IDataInitialize    *pIDataInitialize  = NULL;
    IDBInitialize      *pIDBInitialize    = NULL;
    LPOLESTR pwszFileName = SysAllocString (OLESTR("c:\\thor.udl"));

    LPOLESTR ppwszInitializationString;

    hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
    assert (hr == S_OK);
    hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize,
        reinterpret_cast<void **>(&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