Microsoft Knowledge Base Email Alertz

(264526) - 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:...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 264526 - Last Review: February 22, 2007 - Revision: 3.2

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

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  (http://kbalertz.com/Feedback.aspx?kbNumber=215838/EN-US/ ) 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.

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
Keywords: 
kbbug kbfix kbqfe kbsna400presp4fix kbsna400sp4fix KB264526
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate