I am not sure if I have a SQL-NS problem or a MMC problem. But hopefully someone has run into and can help.

I am developing an Microsoft Management Console (MMC) snapin that uses the SQL Namespace (SQL-NS) COM interface (I have SQL Server 2000 installed so all SQL components are available). Under certain situations I recieve the error message "Unspecfied error" (HRESULT x80004005) when calling the SQL-NS Initialize method.

This error only occurs when I start MMC, "add" the snapin, and then cause the SQL-NS Initialize method to be invoked. If I load my MMC from a saved .msc file and invoke the SQL-NS Initialize method the error does not occur.

Other interesting facts:

- On my Win2K system, the error may not occur the first few
times but once it does it appears to require a reboot to clear
it up.
- On my WinXP test system, the error always occurs when "adding"
the snapin but also never occurs when loading from a saved
.msc file.
- I did some testing using a MFC application and could not reproduce
the problem.
- I can instantiate and use other COM Interfaces, such as SQL-DMO,
with no problems.

The following paraphrases the test code I use, which doesn't seem to be the problem:


// Import SQL-NS type library.
#import "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlns.RLL" no_namespace

VARIANT var;
ISQLNamespacePtr SqlNsPtr; S_OK

try {
SqlNsPtr.CreateInstance(__uuidof(SQLNamespace));

VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(L"Server=127.0.0.1;Trusted_Connecti on=Yes;");
SqlNsPtr->Initialize(L"SQL-NS MMC", SQLNSRootType_Server, &var, NULL);

MessageBox(NULL, L"Initialized SQL-NS", L"Init Worked", MB_OK);

// More code ...
}
catch (_com_error &ce)
{
MessageBox(NULL, ce.ErrorMessage(), ce.Description(), MB_OK);
}


Darrel