Exception Handling in custom control in .NET
wakestar
Member Posts: 207
Hello experts 
I wrote my own custom control (WinForm) in .net using c#. It exposes several methods and events to Navision through COM-Automation.
There are situations where exceptions (critical and noncritical) can be throwed in the .Net- Control. And then ERRORs may also occur in Navision.
Questions:
- How do you manage exceptions throwed in .NET? (I'm not asking how "try catch finally" works in .NET).
What I did is: catch non-critical exception in .NET and pass the Exception-Message to Navision through an event and display it in Navision with MESSAGE(ExceptionMessage).
- How do you manage Navision ERRORs throwed by Navision between some events fired by the .net control?
(The CLR throws Navision ERRORs as COMExceptions... unfortunately I cannot recognize that Navision throwed them:$exception.TargeSite.base.Name =ForwardCallToInvokeMember)
Thanks for your input
I wrote my own custom control (WinForm) in .net using c#. It exposes several methods and events to Navision through COM-Automation.
There are situations where exceptions (critical and noncritical) can be throwed in the .Net- Control. And then ERRORs may also occur in Navision.
Questions:
- How do you manage exceptions throwed in .NET? (I'm not asking how "try catch finally" works in .NET).
What I did is: catch non-critical exception in .NET and pass the Exception-Message to Navision through an event and display it in Navision with MESSAGE(ExceptionMessage).
- How do you manage Navision ERRORs throwed by Navision between some events fired by the .net control?
(The CLR throws Navision ERRORs as COMExceptions... unfortunately I cannot recognize that Navision throwed them:$exception.TargeSite.base.Name =ForwardCallToInvokeMember)
Thanks for your input
0
Comments
-
Hi Wakestar,
I tend to do exactly what you have described wrt passing errors back to Navision and then show the error via Navision.
When catching Navision errors I just catch the COMExceptions because they must have been thrown by Navision (unless the instance of your COM control is shared across multiple applications).This isn't a signature, I type this at the bottom of every message0 -
Hi SteveO
I'm using the Outlook PIA (Primary Interop Assembly) within my control which may throw COMExceptions. But then the $exception.TargeSite.base.Modul is '{Outlook.dll}'.
I think I will send COMExceptions only from this Modul back to Navision.
Otherwise I'm getting the same Error-Message twice in Navision ...first time with ERROR('navision is not happy') and then as a COMException in the CLR.
What do you think?0 -
I would probably ignore exceptions where the Module is not Outlook.dll (because then it is most likely Navision) and then do whatever action is necessary only with the Outlook.dll exceptions.
Can't really think of any alternatives right now.This isn't a signature, I type this at the bottom of every message0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions