Why isn't a dll loading when I open my solution? - visual-studio

I have a solution (Visual Studio 2008) that contains a couple of products. One of these products contains a control that was developed by a colleague that requires loading of a dll. The dll must be loaded when the solution is loaded so that I can view and use the control. However, I am getting errors in the error window saying the control is not defined. When I look on another system (Windows XP Pro) that has VS installed and uses this product and dll, it works fine. However, when I try to load it on my system (Windows 7), I get the errors.
I used Process Explorer on both systems to verify that the dll in question is being loaded. On the XP system where everything works fine, I can see the dll needed is being loaded from C:\windows\system32. I have the dll in the same location (c:\windows\system32) on my Windows 7 box. However, when I load the solution on the Windows 7 box, I can see through Process Explorer that the dll does not load. I know c:\windows\system32 is in the path and I can see other dlls from windows\system32 have been loaded by the visual studio executable image. Why wouldn't this dll be loading? Is there some logging mechanism within VS that will tell me at load time (when I load the project containing the control) why the dll will not load?
Is this a Windows 7 thing? Should I not be putting a developed dll in windows/system32?
Help is appreciated.
Thanks.

Hmm the only thing i have in mind is if the .dll is 32bits and you are making a 64bits application they could be incompatible.

One handy trick I use all the time to deal with dll loading issues is to turn on fusion logging. With that, loading exceptions will be logged to a file, where you can see what might be missing or where the framework is probing for it.
To turn it on, set the following registry keys:
HKLM\Software\Microsoft\Fusion\ForceLog registry value to 1 and HKLM\Software\Microsoft\Fusion\LogPath registry value to C:\FusionLogs (this path must exist)
More info on it:
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx http://msdn.microsoft.com/en-us/library/e74a18c4(v=VS.90).aspx

Related

Problems with FM20.dll and crystl32.ocx while opening VB6 project

A client has recently given me some work involving their (old) VB6 program. I've successfully installed VB6 in a VM with Windows XP (32 bit), and it works just fine. The problem is when I try to open the client's program. The following messages pop up:
crystl32.ocx could not be loaded--Continue Loading Project?
FM20.DLL could not be loaded--Continue Loading Project?
After that there are a bunch of warnings cause of crystl32.ocx.
So I tried to register the dependencies with regsvr32, but it said that the modules couldn't be found, even though they were right there. Googling the problem took me to download Dependency Walker and find which dll files were needed for those files, which were:
msvcr100.dll
IEShims.dll
wer.dll
crpe32.dll
After downloading these dll files, I tried registering the first one, but it said that the "dllregisterserver entry point was not found". So I tried to unregister it first, but it couldn't find the module.
I've reinstalled VB6 several times, to no effect. Any ideas on how to make this work?
Crystl32.ocx and Crpe32.dll are Crystal Reports run time files.
FM20.DLL is Microsoft Form 2.0 Library with some standard GUI controls like label, text box, check box etc.
Msvcr100.dll is a part of
MS Visual C++ 2010 Redistributable Package
If there is an installer of your client's program you should run it before opening the source code with VB6 IDE. That way you’ll get all the dependencies required by VB6 program.
If not, please post the vbp file of your VB6 application.
thanks for all the help! The solution in the end was the installation of the CR 4.6 that the client later provided me with (as #BrianMStafford suggested), of VB6 SP6 and of Office 2007, together with SP3.
With that I've managed to get the project running, so thanks to everyone!!

vb6 not able to load forms with status bar control on windows 7 64 bit

I am trying to load open vb6 form but it says cannot find project or library and the cursor is pointing to statusbar. This particular line of code:
Private mStatus As StatusBar
I have installed the common controls for vb6 update from Microsoft but it's still not doing the job.
I have also tried this :
not able to open VB project, getting error "C:\windows\system32\mscomctl.ocx" could not be loaded
and
regsvr32 mscomctl.ocx
regsvr32 mscomct2.ocx
regsvr32 comct332.ocx
and closed vb6 down, reopened the project and tried to open the form with the control and it gave me same error message.
The edition is enterprise with sp6 installed.
Any advices to fix the issue will be much appreciated.
Thanks!
I had this problem moving projects from XP 32 bit to Win7 64 bit, and aven after getting VB6 apparently working using the various helpful instructins on this site, every time I tried to load up an existing project it failed on opening the project.
Eventually I fixed it by editing (with Notepad) the reference lines in the .VBP project file, which had C:\WINDOWS\SYSTEM32 hard coded in, to point to C:\Windows\SysWOW64.
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\SYSTEM32\STDOLE2.TLB#OLE Automation
Change to
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\SysWOW64\STDOLE2.TLB#OLE Automation
Project files now open up and compile fine. But presumably I will have a similar difficulty if I try to open modified projects on a 32 bit system again.
Found Solution!
Add MSCOMCTL.OCX in SysWOW64(64-bit) or System32 (32-bit) folder
Project - Component - Click Browse and give path to the above file
Download Microsoft Visual Basic 6.0 Common Controls
and install
No OCX missing errors after that

Unable to launch installed application created from Visual Studio Installer when installed in %ProgramFiles(x86)%

I just completed my application development efforts on a D2D1 application using Visual Studio 2010 IDE in C++. I was exploring different ways of creating a package from this and used the built-in Visual Studio installer/setup. The setup project compiled smoothly and an install file was created. I was also able to successfully install the application according to my requirements. However, when I install it in the default location (which would be my preferred location - C:\Program Files(x86)), the application refuses to launch. Here is the debugging I was able to do so far:
Installed in C:\Program Files(x86): Application does not launch normally.
Installed in C:\Program Files(x86): Application launches when "Run as administrator"
Installed in a location other than %ProgramFiles% or %ProgramFiles(x86)%: Application launches normally without having to "Run as administrator".
I have tried cornering the error cases, but don't have anything conclusive or convincing so far, which is why I am seeking the experts help here. What I have done further:
Used Dependency Walker x86 version to figure out where/what the dll calls are through the profiler. It did not provide me with anything concrete - depends.exe believes my application has delay-load dependent modules GPSVC.dll and IESHIMS.dll and I am fairly certain that I don't need those. The profiler also indicates a CRT 0xC0000417 error - but it is difficult for me to say if it is related at all.
I do have a manifest defined for my visual styles as a pragma. Removing this did not help.
If this helps - my C++ project manifest file options in the Linker settings looks like this:
Generate Manifest - Yes
Allow Isolation -Yes
Enable UAC - Yes
UAC Execution level - As invoker
UAC Bypass UI Protection - No
I have converted all CRT functions to it's secure version (sprintf -> sprintf_s) as recommended by MSDN documentation. Is this even related here?
I have tried simply copying the .exe to %ProgramFiles(x86)%. It did not help - so it appears that my installer is not the one creating the problem.
I use _dupenv_s in several places within the code to retrieve %COMSPEC% , %TEMP% etc.
Any pointers to how I can proceed further with the debug is highly appreciated. I did read around about this and some experts suggest incorrect string handling or large or invalid directory names; but I don't see that as relevant in my case since the issue is unique to launching the application normally under %ProgramFiles(x86)% .
Other details:
* OS Windows 7 - 64 bit, Vista with latest SP - 32 bit
* Visual Studio Professional 2010, C++ Project with .Net client profile target
Visual Studio Installer; Target platform 32 bit
* Nature of application - Direct2D based
Pardon me if I did not use the correct technical terms. I am a novice in application deployment.
That is correct Viswanathan, you cannot write to Program Files/Program Files(x86) if you are not running from an elevated process.
If your application needs to write custom settings in a file when it is launched you should create a dedicated folder for it under CommonAppDataFolder

Tracing an executable file compiled in visual studio

How can we trace a compiled application from windows 7. I can see in the event viewer that some DLL files which my program is trying to fetch are causing problems but I can't figure out why.(This is with qtcored4.dll)
You can solve DLL loading problems with Dependency Walker, either by looking at the exe (just open it) or tracing DLL load process by starting profile.

What version of the C Run-Time Library (CRT) is being loaded?

I have an error that I suspect might be caused by different versions of the CRT being loaded on two computers running Windows 7. How do I determine which version of MSVCR90.dll in the winsxs folder is being loaded?
My program is a DLL being loaded by another EXE. It is compiled using Visual Studio 2008 SP1.
As Al Kepp answered, you can use Dependency Walker, "Depends.exe". For DLLs that are dynamically loaded, the best way is to profile the application as it loads your library.
In Dependency Walker open the EXE, not your DLL. Then click "Profile-->Start Profiling". If the application requires arguments you can provide them in the window that opens, otherwise just click "Ok" to launch the program. Once the program is open, use it in the normal way so that it loads your DLL. Now that your DLL is loaded, you should be able to browse the tree in Dependency Walker to see which versions of the CRT are being used.
If you can't see the version, ensure that the full paths are shown in the tree by clicking the "C:\" button.
You can also see which version of the CRT the application or library is requesting by checking the manifest, which is generally, but not always included in the DLL or EXE. in Visual Studio, click "File->Open->File..." and select the EXE or DLL. Open the RT_MANIFEST resource and you should see some XML which lists the CRT as a dependency and the version.
Most applications using these language libraries in DLL files use simply the latest version of those DLL in Windows directory. If you for some reason need some specific version, the easiest what you can do is probably to put those correct files to the same directory as your exe.
You can use Dependency Walker application to see which DLL files are loaded into your process on startup. You can download it from Microsoft site for free.

Resources