473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Access violation when loading DLL with long path


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
4 6866
"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


"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
"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


"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Allen | last post by:
Hi all, I tried posting to one of the ms.win32 groups and haven't gotten a response yet. It may be my C++ that's at fault anyway so I'll try here too. I wrote a .dll that is misbehaving...
3
by: Kyle Teague | last post by:
I have a list of pointers to structs as a private member of a class. If I call begin() in the same function as I added the data then no access violation occurs. However, if I try to call begin() in...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
8
by: Stephen K. Young | last post by:
If you have not seen it, this recent Microsoft Knowledge Base article is worth reading: http://support.microsoft.com/kb/889588 "How to optimize Office Access and Jet database engine...
0
by: techie | last post by:
I have created an event sink in my ATL COM project. The event sink receives events from a C# component. There is no problem with receiving events but when my COM object is released I get an...
1
by: =?Utf-8?B?c2F0aGVlc2t1bWFy?= | last post by:
In my project i have a component named PTS Engine which is developed in VC++ ..Net 2003. And it is migrated to VC++.NET 2005 version. Initially this migration process has coded and tested in VC++...
2
by: =?Utf-8?B?c29jYXRvYQ==?= | last post by:
Hi, I have a DLL in VC6, when a specific function is called it will spawns a few threads and then return. The threads stay running and inside one of these threads an event is created using the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.