I use try and catch to catch unexpected errors in my applications. But I cannot catch those "application error"-messages that appear when the program tries to write in forbitten memory locations.
Is there a way to catch them?
Printable View
I use try and catch to catch unexpected errors in my applications. But I cannot catch those "application error"-messages that appear when the program tries to write in forbitten memory locations.
Is there a way to catch them?
Hi,
The program does not try to write in fordiden memory locations.... by itself :ehh:Quote:
Originally Posted by tobiaswalter
Do you have some code to show us?
Unfortunately not, because the error comes from an ActiveX-Com-Control I use in my .net-code.
However, I'm not trying to find this special error - I'm looking for a way to catch those type of errors.
humm
So the error is inside an Activex-COM control. I suppose yo tried with
VB Code:
try yourdll.youmethod catch ex as exception '.... end try
and it did not work
Also I suppose this control works fine with VB 6.
So there is something i got from .net help
[/QUOTE]Visual Studio .NET usually does a good job of creating interop assemblies, but sometimes you need to optimize the code it generates. Problems with interop assemblies occur because type libraries do not always have all the necessary information to handle some kinds of data marshaling. If an interop assembly does not seem to work correctly, or if you notice performance problems when accessing a COM object using an interop assembly, you may need to manually edit the interop assembly to specify data marshaling. The ability to modify interop assemblies also makes it possible to call methods that are not compatible with OLE automation and that cannot be called using Visual Basic 6.0.
[/QUOTE]
search for Troubleshooting .NET Interoperability on the help you will find the full technical article
Hope this helps
Thank you for your reply.
I tried the try-catch-block, yes.
My intention is not to fix this special error, but to be able to catch all the errors of this type. The error I described is just an example which causes such an error I want to catch.
With try-catch, I cannot 'hold' this error within my application and handle it there - the user notices this error. And this is it, which I would like to suppress
This happens because the error happens inside the control and as far as i know .net does not have control on it.
So the only way I Know to skip this error is try to do it inside the interop file that .net creates to allow use of this COM controls
.NET still supports the old Error handling techniques where you create a function in a function and use it when there is an error.
Try using
VB Code:
On Error GoTo Err_Trapper Err_Trapper: If Err.Number = YourErrorNumber Then 'Display Message Exit Sub End If
no, On Error didn't works either :(
You need to Know the erroe you are trying to handle then you handle it.
Maybe its number, descrpition, type...etc