fatal error C1084: Cannot read type library file, Error loading type library/DLL.

I am developing on Vista and Visual Studion 2008.

I have a simple ATL application which imports one COM dll "xyz.dll"

#import "C:\abc\xyz\xyz.dll" named_guids rename_namespace("UTL") rename("DeleteFile", "XYZDeleteFile")

But I get an error :
1>d:\test\temp\temp\stdafx.h(25) : fatal error C1084: Cannot read type library file: 'C:\abc\xyz\xyz.dll': Error loading type library/DLL.

I am able to open 'xyz.dll' in OLE Viewer. It opens fine and shows all interfaces and coclasses.

aossdevAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deepu AbrahamR & D Engineering ManagerCommented:
check your dll is registered using Regsvr32?
0
Deepu AbrahamR & D Engineering ManagerCommented:
0
aossdevAuthor Commented:
I had tried registering/build that COM dll. It did not  help.
I had seen the above link, It did not help.
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Deepu AbrahamR & D Engineering ManagerCommented:
If you have the IDL-file. You can use mktyplib or midl to generate the tlb-file.

So, if you only have a COM dll, you need to get an idl-file from it:

1. Visual Studio, start it and go to the meny Tools->OLE/COM Object Viewer

2. In that application, select meny File->View Typelib..

3. Select the COM dll and you will see the Typelib.

4. Select the meny File->Save as. Save it with an appropriate name. For example "mycom.idl"

5. start midl.exe or mktyplib.exe with the idl-filname as the argument. "midl mycom.idl"

Read MSDN for more info about midl and mktyplib

then try importing the tlb
0
Deepu AbrahamR & D Engineering ManagerCommented:
0
aossdevAuthor Commented:
Have a COM dll, you need to get an idl-file from it:

1. Visual Studio, start it and go to the meny Tools->OLE/COM Object Viewer

2. In that application, select meny File->View Typelib..

3. Select the COM dll and you will see the Typelib.

4. Select the meny File->Save as. Save it with an appropriate name. For example "mycom.idl"

5. start midl.exe with the idl-filname as the argument. "midl mycom.idl"
I get an error :
: error MIDL2025 : syntax error : expecting a type specification near "LogMessageType"
: error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
 LogMessageType is enum defined some where down in IDL file. When I open this COM dll (xyz.dll) in OLE Viewer it opens up nice and also shows the enum defined.
0
aossdevAuthor Commented:
If I am correct it is not able to find the definition any ENUMs. As one by one it is complaining about all the ENUM for type specification. We can resolve this by moving the ENUM definition to the interface definition in IDL file.
But:
1. Is this the right approach?
2. What if two interfaces shares one ENUM. Defining the ENUMs in both the interfaces is just not sounding good.
Thanks,
0
aossdevAuthor Commented:
Coming back to main problem:
But I get an error :
1>d:\test\temp\temp\stdafx.h(25) : fatal error C1084: Cannot read type library file: 'C:\abc\xyz\xyz.dll': Error loading type library/DLL.


If I run my VS 2008 IDE not as an administrator then this compiles fine. And xyz..tlh/.tli  gets generated correctly. Problem is If I don't run my IDE as an adminsitrator then I get an error:-
1>Performing registration
1>Project : error PRJ0019: A tool returned an error code from "Performing registration"
0
aossdevAuthor Commented:
1. One of the dependecy (*.tlb) for xyz..tlb was registered in Administrator(User) log in.
2. Then xyz.dll was built again in normal user.
3. Now OLEViewer was open in Admin mode and it was able to open xyz.dll
4. And also VS 2008 IDE in admin mode was able to compile the code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.