Hi. I have created an WindowsFormsApplication with multiple forms, and in a form I added an ShockwaveFlashObject and i set it a .swf file. The problem is that when I access two or three forms and come back to this form, it shows me this error message:
An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I don't really know how to fix this, I just managed to find out that this is the problem.
The ShockwaveFlashObjects was added to toolbox from COM Components.
Unfortunately it is not easy. You will have to do some, or even a lot of, debugging in order to discover where in the application the access violation occurs. The most likely cause is passing a bad reference to some library method, but you would need a detailed stack trace to start investigating.
I don't really know how to make such a deep debugging, because it doesn't show me the line where the error occurs, it just shows me that message when I close the application and that's it..If I remove ShockwaveFlashObjects and AxShockwaveFlashObjects from reference and the item from form, it works perfectly, so that is the issue
Like I said: it's not easy. There is no way that anyone can guess the answer for you. You will have to add some code to your application to get more information about what is going on, until you can narrow it down to the general area where the problem occurs. That is when you can start tracing through with your debugger.
I managed to fix the issue. The problem was that that flash object remains active when you open another form and it must be stopped or disposed. This is the solution, if anybody will get this error in this situation.
Correct you are. But, Eddy's pointing to the fact the code could be "cleaner" if re-factored is spot-on, and, the remedy is simple:
publicvoid Add(string text)
// And, you can compile-time check for type of T is Nullable:// in the Class' 'ctorif (default(T) != null)
thrownew InvalidOperationException("requires T to be a nullable type.");
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.