DotNet Interop and Exception Handling

wakestar
Member Posts: 207
Hi all
Since we are not able to catch .NET Exceptions in NAV.... I wonder what the preferred workaround is?
At the moment I can think of the following workarounds:
- write a generic .net assembly which uses reflection to call the classes and methods and handles the exceptions in a generic way
- write c# scripts on the fly and use an external engine like CS-Script
- write c# scripts on the fly and use .net internal classes with DotNet Interop to run the script (not sure if that works)
Any other ideas or recommendations?
How do you handle it?
Since we are not able to catch .NET Exceptions in NAV.... I wonder what the preferred workaround is?
At the moment I can think of the following workarounds:
- write a generic .net assembly which uses reflection to call the classes and methods and handles the exceptions in a generic way
- write c# scripts on the fly and use an external engine like CS-Script
- write c# scripts on the fly and use .net internal classes with DotNet Interop to run the script (not sure if that works)
Any other ideas or recommendations?
How do you handle it?
0
Comments
-
Have you try the ASSERTERROR, GETLASTERRORTEXT combination ?
Regards.0 -
No, I haven't tried that. I guess it's good for catching the error without wasting an "IF NOT Codeunit.RUN()"?
In case you need the actual exception message.. you're stuck right?
As an example: WebRequest.GetResponse() throws an WebException and you want to know wheter the http status code is 500, 404 or 200
https://msdn.microsoft.com/de-de/library/system.net.httpwebrequest.getresponse%28v=vs.110%29.aspx
I'm looking for a solution without the installation and deployment hassle.0 -
To get the actual exception message is what the GETLASTERRORTEXT is for.
Regards0 -
You can read through Vjeko's thoughts on the topic, and see if there's anything that you can use in your case:
http://vjeko.com/tags/exception-handlingVytenis Jakas
B3 Technologies - Making Technology Serve the People0 -
hi there
thanks, yes I saw vjeko's blog
My original question was: which of the different solutions (read:workraounds) do you use and why?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions