By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,492 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,492 IT Pros & Developers. It's quick & easy.

Access violation when loading DLL with long path

P: n/a

I am attempting to use an API (CxApiOem.dll) that has a large number of
defines and complicated structs. It's just too much hassle to attempt
to use DLLImport to make the desired API calls. Instead, I created a
managed C++ DLL (OneBoxAPI.dll) that wraps the desired API calls in a
manner which is easy to call from C#. This way I can use the header
files that are part of the API for all the defines and structs.

I am having a problem using the managed C++ DLL. When the DLL is
located in a directory which has a long path (> approx 80 char), then
the DLL fails to load. If I move everything to a place where the path
to the DLL is much shorter, then without recompiling or anything, it
loads just fine and everything works as expected. Below you can see
the output from Visual Studio while running my app in debug mode.

Anybody have any ideas as to why the path length appears to cause an
access violation when loading the managed C++ DLL?
//------------------------------------------------------------------------
// Fails to load OneBoxAPI.dll when in dir with long path
//------------------------------------------------------------------------

'Import Wizard.exe': Loaded 'C:\Documents and Settings\eusbmat\My
Documents\Visual Stuido Projects\Import Wizard\bin\Debug\OneBoxAPI.dll',
Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msvcr71d.dll', Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\CxApiOem.dll', No symbols
loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\version.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\lz32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\AT_WAVE.DLL', No symbols
loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msacm32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\winmm.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msvcp71.dll', Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\Dcp32.dll', No symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\mmdrv.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\mmdrv.dll'
First-chance exception at 0x7463656a in Import Wizard.exe: 0xC0000005:
Access violation reading location 0x7463656a.
'Import Wizard.exe': Unloaded 'C:\Documents and Settings\eusbmat\My
Documents\Visual Stuido Projects\Import Wizard\bin\Debug\OneBoxAPI.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\CxApiOem.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\Dcp32.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\AT_WAVE.DLL'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\msvcp71.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\msacm32.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\winmm.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\version.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\lz32.dll'
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\msvcr71d.dll'

//------------------------------------------------------------------------
// Move Visual Studio Projects directory to C: and then it loads just fine
//------------------------------------------------------------------------

'Import Wizard.exe': Loaded 'C:\Visual Stuido Projects\Import
Wizard\bin\Debug\OneBoxAPI.dll', Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msvcr71d.dll', Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\CxApiOem.dll', No symbols
loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\version.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\lz32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\AT_WAVE.DLL', No symbols
loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msacm32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\winmm.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msvcp71.dll', Symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\Dcp32.dll', No symbols loaded.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\mmdrv.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Unloaded 'C:\WINNT\system32\mmdrv.dll'
'Import Wizard.exe': Loaded 'C:\WINNT\system32\NETAPI32.DLL', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\secur32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\ntdsapi.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\dnsapi.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\wsock32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\ws2_32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\ws2help.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\wldap32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\netrap.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\samlib.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'c:\visual stuido projects\import
wizard\bin\debug\oneboxapi.dll', Symbols loaded.
OneBox session created.
Initializing OneBox session
'Import Wizard.exe': Loaded 'C:\WINNT\system32\rnr20.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\iphlpapi.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\icmp.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\mprapi.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\activeds.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\adsldpc.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\rtutils.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\setupapi.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\USERENV.DLL', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\rasapi32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\RASMAN.DLL', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\tapi32.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\dhcpcsvc.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\winrnr.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\rasadhlp.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\msafd.dll', Cannot find or
open a required DBG file.
'Import Wizard.exe': Loaded 'C:\WINNT\system32\wshtcpip.dll', Cannot find or
open a required DBG file.
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Matt Sawyer" <Ma********@discussions.microsoft.com> wrote:
I am attempting to use an API (CxApiOem.dll) that has a large number of
defines and complicated structs. It's just too much hassle to attempt
to use DLLImport to make the desired API calls. Instead, I created a
managed C++ DLL (OneBoxAPI.dll) that wraps the desired API calls in a
manner which is easy to call from C#. This way I can use the header
files that are part of the API for all the defines and structs.

I am having a problem using the managed C++ DLL. When the DLL is
located in a directory which has a long path (> approx 80 char), then
the DLL fails to load. If I move everything to a place where the path
to the DLL is much shorter, then without recompiling or anything, it
loads just fine and everything works as expected.


Mixed-mode DLLs, those including both managed and unmanaged code, are
susceptible to a devious problem called the Mixed DLL Loading Problem, which
can cause unpredictable effects during loading of such DLLs. This may not be
your problem in this case, but it is likely to be *a* problem. Take a look
at this article:

http://msdn.microsoft.com/library/en...ingProblem.asp

I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 16 '05 #2

P: n/a


"Derrick Coetzee [MSFT]" wrote:
Mixed-mode DLLs, those including both managed and unmanaged code, are
susceptible to a devious problem called the Mixed DLL Loading Problem, which
can cause unpredictable effects during loading of such DLLs. This may not be
your problem in this case, but it is likely to be *a* problem. Take a look
at this article:

http://msdn.microsoft.com/library/en...ingProblem.asp

I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.


Thanks for the response. Unfortunately, I have already followed the steps
from that article to remove the entry point for the DLL. So, while my
problem might still be related to the known issues with loading mixed DLL's,
the solution in that article doesn't solve my problem.

The problem is definitely related to path length and I have further
discovered the following:

If the total path (including DLL filename) is 69 char or more, such as:

C:\Documents and Settings\eusbmat\My Documents\Impt Wiz\OneBoxAPI.dll

then I always get a System.IO.FileLoadException. If the total path is
exactly 68 char, such as:

C:\Documents and Settings\eusbmat\My Documents\Imp Wiz\OneBoxAPI.dll

then the application terminates without an error of any sort. The app just
disappears at the point it attempts to load the DLL. If the total path is 67
char or less, such as:

C:\Documents and Settings\eusbmat\My Documents\Im Wiz\OneBoxAPI.dll

then the DLL always loads just fine. This is very bizarre behavior.

The enviornment I'm using is:

Windows 2000 Professional (SP4)
Visual Studio .NET 2003 (7.1.3088)
..NET Framework v1.1 (1.1.4322)

Nov 16 '05 #3

P: n/a
"Matt Sawyer" <Ma********@discussions.microsoft.com> wrote:
If the total path (including DLL filename) is 69 char or more [...]
then I always get a System.IO.FileLoadException. If the total path
is exactly 68 char [...] then the application terminates without an
error of any sort. The app just disappears at the point it attempts
to load the DLL. If the total path is 67 char or less[...] then the
DLL always loads just fine. This is very bizarre behavior.


Bizarre indeed, and with the distinct odor of a buffer overflow occurring
somewhere in the .NET Framework code. You may want to try the same
experiment with the Visual Studio 2005 beta and version 2.0 of the .NET
Framework - it's possible this is a bug that has been fixed. Also, make sure
you've installed the .NET Framework SDK, and then use the tool fuslogvw.exe
(Fusion Log Viewer) to check for any more detailed log messages about its
failure to load the assembly. If your problem is still not solved, we can at
least use this information to file a bug with the appropriate team and find
a workaround.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 16 '05 #4

P: n/a


"Derrick Coetzee [MSFT]" wrote:
Bizarre indeed, and with the distinct odor of a buffer overflow occurring
somewhere in the .NET Framework code. You may want to try the same
experiment with the Visual Studio 2005 beta and version 2.0 of the .NET
Framework - it's possible this is a bug that has been fixed. Also, make sure
you've installed the .NET Framework SDK, and then use the tool fuslogvw.exe
(Fusion Log Viewer) to check for any more detailed log messages about its
failure to load the assembly. If your problem is still not solved, we can at
least use this information to file a bug with the appropriate team and find
a workaround.


I don't have time right now, but I can try VS 2005 & .NET 2.0 sometime down
the road. I did try running the Fusion Log Viewer, but it was empty, so it's
not an issue with binding to the assembly. I'm pretty much convinced at this
point that it's a bug and not a configuration error of some sort. So, when I
get a chance, I'll try 2.0 and if it still fails, I'll submit a bug report to
MS. Thanks for trying to help though, it was very much appreciated!

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.