Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We are converting our projects from vs2005 to vs2015. We able to clear the build error but now we are getting runtime error at LoadTypeLib function call

Error is "Error loading type library/DLL"

Below is the code
HRESULT LoadTypeInfoFromThisModule(REFIID riid, ITypeInfo **ppti) 
{
	*ppti = 0;
    char szFileName[MAX_PATH];

    GetModuleFileNameA((HMODULE)moduleHandle, szFileName, MAX_PATH);

    OLECHAR wszFileName[MAX_PATH];

    mbstowcs(wszFileName, szFileName, MAX_PATH);

    ITypeLib *ptl = 0;

    HRESULT hr = LoadTypeLib(wszFileName, &ptl);

    if (SUCCEEDED(hr)) 
	{
        hr = ptl->GetTypeInfoOfGuid(riid, ppti);
        ptl->Release();
    }

    return hr;
}

May I know why this error will be thrown. The same code is working fine in vs2005

What I have tried:

If i use the vs2005 dll with in VS2015 project then it able to load
Posted
Updated 4-Jul-17 4:43am
v2
Comments
Dave Kreskowiak 4-Jul-17 11:26am    
Or different architecture between the process and the .DLL being loaded. You cannot load a 32-bit .DLL into a 64-bit process or the reverse.

1 solution

These error messages are weired but true. It can be that the dll is in a different directory or some string changes from ASCII to UNICODE.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900