|
-
Jul 13th, 2007, 03:23 PM
#1
[2005] Recently occurring problems with DLL's
I have an application which has worked fine for the last ~3 years. Right now though, it's started throwing an exception;
"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
This occurs when running a sub in an external DLL (which is one my own DLL's). This has only started within the last month or so and happens on the same computer it was developed on and happens if I open the source and run it in the IDE. I cant see anything wrong with the code, if I skip over the sub it crashes on, it then crashes on the next sub.
Oddly, it also seems to only crash the first time it runs a sub within the DLL. So if I run the same sub 10 times, it only crashes on the first execution of it, the next nine times are fine.
I suspect it may be caused by KB939373 (security update for XP) or KB936357 (update for XP). It might also be some kind of initialization problem where the DLL cannot be read or something as the program starts up.
Anyone else seen this?
-
Jul 13th, 2007, 03:32 PM
#2
Re: [2005] Recently occurring problems with DLL's
Nope, but it does sound like an issue with the object being created, which is why it fails on the first attempt. Then the rest of the times its already created so it runs fine.
Could it be possible that the error is not in the suspect sub but the one after?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 13th, 2007, 03:52 PM
#3
Re: [2005] Recently occurring problems with DLL's
I put a break after the first DLL sub is run (so no subsequent sub runs) and it fails on the first execution. The DLL call is defined like this;
Code:
Private Declare Sub TimeDate Lib "Resources\MyAppName.dll" ( _
ByRef DateCode As String, _
ByRef TimeString As String, _
ByRef DateString As String, _
ByRef TimeStampValue As String, _
ByRef dayi As Integer, _
ByRef monthi As Integer, _
ByRef yeari As Integer)
The DLL returns some date/time codes, it has no inputs.
But... in debugging (as you suggested!) I found something...
Code:
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load, MyBase.Load, MyBase.Load, MyBase.Load
If I set the handles to carry just one load, it now works fine. I have no idea how four identical handles appeared in that header, but they must have been there for a very long time. But its only now after many years its causing a problem though. Weird.
-
Jul 13th, 2007, 04:07 PM
#4
Re: [2005] Recently occurring problems with DLL's
I cant imaging how that could have happened either but glad its solved. That could have been a tough one to figure out if that wasnt the solution. 
Thanks 
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 13th, 2007, 05:59 PM
#5
Re: [2005] Recently occurring problems with DLL's
Actually, this problem came back on bit me on the backside a bit later. So earlier I found a problem but not the cause. However, after 5 hours of messing about I have fixed it as shown below.
Code:
Private Declare Sub TimeDate Lib "Resources\MyAppName.dll" ( _
<MarshalAs(UnmanagedType.LPStr)> ByRef DateCode As String, _
<MarshalAs(UnmanagedType.LPStr)> ByRef TimeString As String, _
<MarshalAs(UnmanagedType.LPStr)> ByRef DateString As String, _
<MarshalAs(UnmanagedType.LPStr)> ByRef TimeStampValue As String, _
ByRef dayi As Integer, _
ByRef monthi As Integer, _
ByRef yeari As Integer)
No matter what I do, I can't break it now.
I still don't understand why this problem has recently surfaced but perhaps it is due to the windows updates I mentioned earlier.
-
Jul 13th, 2007, 07:36 PM
#6
Re: [2005] Recently occurring problems with DLL's
More then likely the Windows Updates are the cause of it showing up if no other changes were done to the system/server like new config changes or new app installs etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|