Can't dynamically load VC8 library?  
Author Message
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

I would say I am beginning to hate manifests... unfortunately, I am already well past that point.

I have an application that dynamically loads a dll (i.e. LoadLibrary()). It worked when I built with VC6. Now that I am trying to build with VC8, I get the following error:
Runtime Error!
Program: <path-to-my-program.exe>
R6034
And application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.

I used to get this error trying to run the application itself, but was able to resolve it. Is there something special that needs to be done to use LoadLibrary now that one has to deal with these awful manifest things


Visual C++15  
 
 
Ayman Shoukry - MSFT





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Where are you trying to load the MSVCR80.dll from

Thanks,
Ayman Shoukry
VC++ Team


 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

I have copies of msvcr80.dll and Microsoft.VC80.CRT.manifest in my program's 'bin' directory, which is also where the .exe and .dll in question are located. I couldn't get anything to run before doing that.

 
 
Ayman Shoukry - MSFT





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Did you build the .dll that you are trying to load

Thanks,
Ayman Shoukry
VC++ Team


 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Yes; the only code involved that is not "ours" are system libraries (e.g. MSVCR80.dll, ws2_32.dll, etc)

 
 
Ayman Shoukry - MSFT





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

For dlls, you need to embed the manifest into the dll that you are trying to load Did you do that If the manifest is already embeded then you don't need to have msvcr80.dll in the current directory and you will need to leave your dll to pick it up from the winSxS directory.

Thanks,
Ayman Shoukry
VC++ Team


 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Yes, the manifests are all embedded; if they weren't, nothing would be working. However, using the WinSxS directory would significantly complicate our install process, and we don't want to do that.

This application is part of a package that contains a number of executables and a larger number of dll's. The executables that do not use LoadLibrary() work. Is there something different about run-time linking (using LoadLibrary()) vs. load-time linking

 
 
Martyn Lovell





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Are you sure the manifests embedded in your DLLs are ID#2 This error happens when two conditions are present

- the DLL does not have a correct manifest AND

- the app-local directory or system32 contain an msvcr80.dll.

I would guess that your DLL (or one of its dependent dlls) either have no manifest, or an ID#1 manifest.

Martyn Lovell

Development Lead

Visual C++ Libraries


 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Yes, they are ID#2. See one of my other threads (http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=476880&SiteID=1) for the command I use to do the embedding.

Again, this only happens with runtime-loaded (LoadLibrary()) dll's. The application loads its regular dynamic-link dll's with no problems.

 
 
Holger Grund





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

I'd take a look at the NT Loader diagnostics. Just enable the ShowSnaps (e.g. via gflags.exe or as I always do it by setting *((char*){,,ntdll.dll}_ShowSnaps)=1 ) and take a look at the de**** output.

-hg


 
 
Holger Grund





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Oh, my bad. I thought you'd get an error return code from LoadLibrary not an abort message. So that is really a manifest issue.

BTW: You can verify that the manifest is present with the resource editor (just open the dll in VC) and use depends.exe to verify it (it'll complain if the manifest is illformed).

-hg


 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

Hmm... Ok, that's strange. I opened up a dll that works, and saw the manifest. Then I opened the one that's giving me problems... and what would you know No manifest...

HOWEVER... I am most assuredly trying to put one there. Looking at my build log, I see:
mt.exe -manifest <my_dll>.manifest -outputresource:<my_dll.manifest>;2
Microsoft (R) Manifest Tool version 5.2.3790.2014

Copyright (c) Microsoft Corporation 2005.

All rights reserved.

<...build continues>

Further, my 64-bit versions of the same dll are OK; only the 32-bit version is problematic.
...So how do I troubleshoot mt.exe apparently failing silently

 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

For reference, here is the contents of <my_dll.manifest> (generated by link.exe):
< xml version='1.0' encoding='UTF-8' standalone='yes' >
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>

 
 
mwoehlke





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

I also tried placing the .manifest beside the dll on my test computer with no luck. Wondering if it was something about the .manifest itself, I compared it to one that works; they are identical. So, it looks like for some reason this particular dll doesn't want to let me give it a .manifest

 
 
Martyn Lovell





PostPosted: Visual C++ General, Can't dynamically load VC8 library? Top

First, an external manifest doesn't ever work on a DLL (only on an EXE), so trying external won't work.

Is your build script checking the errorlevel after spawning mt.exe

I suspect that your mt.exe command line is wrong. It looks like you are missing a # symbol - see the mt.exe help - the syntax for output resource is -outputresource:dllname.dll;#2

Try that.

Martyn Lovell

Development Lead

Visual C++ Libraries