Stonkie
Well-known member
- Joined
- Sep 12, 2007
- Messages
- 279
- Programming Experience
- 1-3
I got an application that loads packages of data (zipped XML files) from file and loads it to an SQL Server database. The whole situation is pretty simple, but I will try to illustrate with sound. <- starting recorder sound here
I'm having an inherited BackgroundWorker do the importation while the user interface simply reports operation progress. <- birds singing sound here
Everything went fine for hundreds of times, then one day, I made a slight modification in the database structure and wanted to make sure everything ran well again so I launch the import and what do I encounter? An AccessViolationException! <- explosion sound here
It happened at a certain point where I get the InnerXML property of an XmlNode. I had a stack trace that went deep in CLR code and threw the exception. <- screaming sound here
My first thought was that the reference to something in the XmlDocument was shared among my threads so I might have a lock missing or something, but the document's reference is a local variable (I read the file from the BackgroundWorker). <- debris falling over my evidences sound here
Here's what I found on Microsoft's site : <- boring technician talking theory sound here
I have no unsafe code and my only unmanaged dll is a Lua interpreter through LuaInterface. And it's used in a totally different part of the application, a few managed dlls away (actually, it has not yet been used when the importation starts). <- beating the crap out of boring technician sound here.
Is there any situation that could cause this exception other than an error in my unmanaged code I don't have? I'm looking for pointers... For what I know XmlDocument and friends don't even have an unmanaged underground structure... <- asking bleeding boring technician sound
And of course, I've been unable to repeat this! I'm giving it a try here so maybe someone has an idea of something I could have done wrong, but if it doesn't cause problems and I don't understand it, I'll probably let it go. <- groan sound
Click <- turning off the recorder sound
I'm having an inherited BackgroundWorker do the importation while the user interface simply reports operation progress. <- birds singing sound here
Everything went fine for hundreds of times, then one day, I made a slight modification in the database structure and wanted to make sure everything ran well again so I launch the import and what do I encounter? An AccessViolationException! <- explosion sound here
It happened at a certain point where I get the InnerXML property of an XmlNode. I had a stack trace that went deep in CLR code and threw the exception. <- screaming sound here
My first thought was that the reference to something in the XmlDocument was shared among my threads so I might have a lock missing or something, but the document's reference is a local variable (I read the file from the BackgroundWorker). <- debris falling over my evidences sound here
Here's what I found on Microsoft's site : <- boring technician talking theory sound here
In programs consisting entirely of verifiable managed code, all references are either valid or null, and access violations are impossible. An AccessViolationException occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.
I have no unsafe code and my only unmanaged dll is a Lua interpreter through LuaInterface. And it's used in a totally different part of the application, a few managed dlls away (actually, it has not yet been used when the importation starts). <- beating the crap out of boring technician sound here.
Is there any situation that could cause this exception other than an error in my unmanaged code I don't have? I'm looking for pointers... For what I know XmlDocument and friends don't even have an unmanaged underground structure... <- asking bleeding boring technician sound
And of course, I've been unable to repeat this! I'm giving it a try here so maybe someone has an idea of something I could have done wrong, but if it doesn't cause problems and I don't understand it, I'll probably let it go. <- groan sound
Click <- turning off the recorder sound