AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.09.2014, 11:00   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006


 </p>


In diesem Artikel geht es nicht um Frank W. Abagnale Jr., den einzigen Teenager, der es je auf die FBI-Liste der zehn meistgesuchten Kriminellen in den Vereinigten Staaten gebracht hat (siehe auch http://www.kino.de/kinofilm/catch-me-if-you-can/66581), sondern um die Ausnahmebehandlung bei der Nutzung von .NET-Variablen in Dynamics NAV.</p>


Jeder der schon einmal etwas mehr im Bereich der Interoperabilität gemacht hat, wird unweigerlich darauf gestoßen sein, dass eine bei Nutzung von DotNet-Klassen auftretende Ausnahme/Exception, die weitere Ausführung des C/AL-Programmcodes verhindert. Das gleiche Verhalten also, wie bei der Nutzung von ERROR(). Die Fehlermeldung wird ausgegeben und die Verarbeitung beendet. Das wird allgemein genutzt, um Fehleingaben zu quittieren oder andere nicht behandelbare Probleme eindeutig abzufangen. Der Vorteil ist, dass Sie im C/AL selbst bestimmen können, wann ein Abbruch der Verarbeitung sinnvoll ist:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">IF kaputt THEN BEGIN</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> Aufraeumen();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> ERROR(<span style="color: #006080;">'kaputt!'</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">END;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Im .NET Framework dient eine Ausnahme ebenfalls genau dazu. Allerdings ist es nicht immer möglich, alle Eventualitäten zu kalkulieren. Prüfen Sie beispielsweise vor dem Schreiben einer Datei per .NET aus C/AL heraus den Zugriff auf einen Pfad, kann dies, einige Millisekunden später, wenn die Ausgabe der Datei über eine .NET-Klasse erfolgen soll, schon nicht mehr so sein. Sei es, dass der Pfad nicht länger existiert, die Berechtigung sich zur Millisekunde geändert hat, ein ferner Computer heruntergefahren wurde oder hunderte andere Dinge, die man sich als Programmierer lieber nicht vorstellt. Jede noch so gut geplante Implementierung und Vorabprüfung wird durch eines immer wieder ausgehebelt: Den Menschen, dessen freien Willen und unendliche Kreativität!</p>


Aber nehmen wir einfach mal an, der Chefentwickler im Hause hat alle, aber auch absolut alle Eventualitäten berücksichtigt. Vom heruntergefahrenen Server, über die Zugriffsrechte, bis hin zum Kaffeekonsum des Administrators. Nehmen wir an, es gäbe eine Methode (Funktion) in einer .NET-Klasse, die auf alles erdenkliche vorbereitet ist. Was tut nun aber eine klassische .NET-Implementierung in dem Fall, dass zwar alles abgefangen und geprüft wird, aber letztendlich festgestellt werden muss, dass die übergebenen Daten nicht passen? Es wird eine Ausnahme erzeugt, die den Aufrufer über die fehlerhaften Daten informiert. Ist der Aufrufer ebenfalls in z.B. C# implementiert, wird dieser (wahrscheinlich) das try/catch-Konstrukt zur Fehlerbehandlung nutzen und dort dann reagieren. Ist der Aufrufer allerdings Dynamics NAV bzw. dortiger C/AL-Code, führt diese Ausnahme zu einem Fehler, die Ausführung wird unterbrochen und die Standardausnahmebehandlung inkl. Datenbank-Rollback wird ausgeführt.</p>


Man darf an dieser Stelle nicht vergessen, dass Dynamics NAV, ob Server oder Client, vollständig in .NET implementiert ist und auch C/AL beim kompilieren im Object Designer in C#-Code übersetzt und später zur Laufzeit in eine DLL kompilert wird, diese Exception also innerhalb einer Klasse PageXY auftritt, in einer Methode ActionXY, in der der C/AL-Entwickler eine DotNet-Variable benutzt hat. Und das alles nur, weil ein Benutzer, seinem freien Willen uneingeschränkt folgend, und ohne Feld XY auszufüllen, auf der Page XY eine Action XY angeklickt hat… Das bedeutet falsche Daten, interne Prüfung, Methode “wehrt sich”, Methode erzeugt Ausnahme, was sich dann so äußert:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">ERROR(<span style="color: #006080;">'kaputt!'</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Auch wenn C/AL und .NET letztendlich im selben C#-Code landen, müssen nach Auftreten von Fehlern (ich meine jetzt aber explizit nicht ERROR() oder eine Ausnahme), eventuell Dinge aufgeräumt, Daten zurückgesetzt oder ein entsprechendes Protokoll geschrieben werden. Das funktioniert aber nur, wenn eine Ausnahme auch von außen (C/AL) abgefangen werden kann.</p>


 </p>
<h3>try-catch</h3>


C/AL unterstützt (noch) kein try-catch-finally-Konstrukt. Eine Möglichkeit wäre also, den Aufruf einer .NET-Methode per try-catch in einer eigenen .NET-Methode zu kapseln und diese neue Methode aufzurufen, die den Fehler sauber abfängt. Dies ist sicherlich sinnvoll für Eigenentwicklungen, aber wer möchte schon für den Fundus von zehntausenden von .NET-Klassen jeweils eine Aufruffunktion programmieren? Das wird vom Entwickler sicherlich direkt bei Anforderung durch Kopfschütteln, ein klares “NEIN!” oder auch andere, den Mittelfinger nutzende Gesten, quittiert.</p>


Die Antwort: Generische Herangehensweise! Das .NET Framework bietet unter anderem auch einen Mechanismus mit Namen “Reflection”. Reflection erlaubt es, .NET-Assemblies zu analysieren, Informationen zu Klassen, Schnittstellen und Wertetypen auszulesen, Instanzen zur Laufzeit zu erzeugen oder Eigenschaften und Methoden ab- oder aufzurufen. Es ist also auch möglich, die Methode einer Klasse direkt mit Namen aufzurufen. Ein Beispiel dazu, wobei classObject eine Klasse vom Typ Decimal ist:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Type objectType = classObject.GetType();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">MethodInfo method = objectType.GetMethod(<span style="color: #006080;">"Divide"</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">method.Invoke(classObject, <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">object</span>[] { 1, 0 });</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Der zweite Parameter von method.Invoke() ist ein Array der übergebenen Parameter (Divident und Divisor) und führt hier natürlich unweigerlich zu einer Ausnahme “Division durch null”. Da wir genau das nicht wollen, was wäre mit folgender Lösung?</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="color: #0000ff;">try</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> Type objectType = classObject.GetType();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> MethodInfo method = objectType.GetMethod(<span style="color: #006080;">"Divide"</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> method.Invoke(classObject, <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">object</span>[] { 1, 0 });</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff;">catch</span>(Exception)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Das funktioniert ohne Abbruch, da die auftretende Ausnahme durch den catch abgefangen wird. Klar wird es eine DivideByZeroException sein, diese erbt aber von Exception, so dass wir mit obigem catch(Exception) die meisten, aber nicht alle Ausnahmen abfangen können. Beispiele für nicht-abfangbare Ausnahmen sind OutOfMemoryException oder StackOverflowException. Es ist eher unwahrscheinlich, dass diese im Benutzer-Code noch korrigiert werden können.</p>


Aber wieder zurück zum Thema: Kapseln wir nun das obige Beispiel in einer eigenen Methode, und übergeben die Klasse/das Objekt, den Methodennamen und die Aufrufparameter als Parameter dieser Methode, dann ist das schon recht generisch. Allerdings müssen wir das Ganze noch ein wenig aufwerten. Denn was passiert, wenn eine Methode überladen ist, es also mehrere Implementierungen (mit verschiedenen Parametern) gibt? Ich denke Sie erraten es: Ein Fehler, denn die Methode kann nicht eindeutig bestimmt werden. Das bedeutet also eine Exception, genau: eine AmbiguousMatchException.</p>


Dafür wiederum gibt es Überladungen der Methode GetMethod(). Eine, die meiner Meinung nach ausreichend zur Identifikation der gewünschten Methodensignatur ist, erwartet zwei Parameter. Den Namen und ein Type[]-Array, mit dem die Art der Parameter übergeben werden kann. Methodensignaturen unterscheiden sich nämlich alle in Menge und Reihenfolge der übergebenen Parameter-Varianblentypen. Daraus ergibt sich dann eine etwas umfangreichere Variante.</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">bool</span> InvokeMethod(<span style="color: #0000ff;">object</span> classObject, <span style="color: #0000ff;">string</span> methodName, List<<span style="color: #0000ff;">object</span>> parameters)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">try</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> List<Type> parameterTypes = <span style="color: #0000ff;">new</span> List<Type>();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">foreach</span>(<span style="color: #0000ff;">object</span> parameter <span style="color: #0000ff;">in</span> parameters)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> parameterTypes.Add(parameter.GetType());</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> Type objectType = <span style="color: #0000ff;">null</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">if</span> (classObject <span style="color: #0000ff;">is</span> Type)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> objectType = classObject <span style="color: #0000ff;">as</span> Type;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> classObject = <span style="color: #0000ff;">null</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">else</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> objectType = classObject.GetType();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> MethodInfo method = objectType.GetMethod(methodName, parameterTypes.ToArray());</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">if</span> (method == <span style="color: #0000ff;">null</span>)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> AmbiguousMatchException();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> LastReturnValue = method.Invoke(classObject, parameters.ToArray());</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">catch</span> (Exception ex)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> InitializeExceptionProperties(ex);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Aus den übergebenen Parametern, die aus Dynamics NAV als generische Liste übergeben werden, wird wiederum eine generische Liste der Typen erstellt, die zur Ermittlung an die Methode GetMethod() übergeben wird. Sie sehen, dass obiger Code noch eine kleine Variante enthält. Es existieren statische und nicht-statische Typen, Klassen und Methoden. Statische Methoden gehören zum Typ selbst und nicht zu einer spezifischen Instanz eines Typs. Dementsprechend erlaubt die Variante oben auch die Übergabe eines Typs (ermittelt über den C/AL Befehl GETDOTNETTYPE()). Wenn gar nichts mehr geht, also eine Methode nicht gefunden wird, dann meldet sich diese Implementierung ebenfalls mit einer Ausnahme zu Wort, hier einer selbst ausgelösten AmbiguousMatchException. Denn in dem Fall, hat offensichtlich der Entwickler etwas übersehen.</p>


Wer nun noch über die Methode InitializeExceptionProperties() gestolpert ist, diese ist im Folgenden aufgeführt. Zusammen mit GetFullExceptionMessage(), welche bis zur innersten Ausnahme alle Ausnahmen-Fehlertexte konsolidiert, werden hier die Ausnahme und der Fehlertext zum Abruf aus C/AL gespeichert und der letzte Rückgabewert auf null gesetzt.</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> InitializeExceptionProperties(Exception exception = <span style="color: #0000ff;">null</span>)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> LastException = exception;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> LastMessage = exception != <span style="color: #0000ff;">null</span> ? GetFullExceptionMessage(exception) : <span style="color: #0000ff;">string</span>.Empty;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> LastReturnValue = <span style="color: #0000ff;">null</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> GetFullExceptionMessage(Exception exception)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">string</span> errorMessage = <span style="color: #0000ff;">string</span>.Empty;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> Exception exception2 = exception;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">do</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> errorMessage += <span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">" - {0}"</span>, exception2.Message);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> exception2 = exception2.InnerException;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">while</span> (exception2 != <span style="color: #0000ff;">null</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> errorMessage = errorMessage.Substring(3);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> errorMessage;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Da ich eigentlich schon wieder zu viel geschrieben habe, möchte ich die zwei übrigen und letzten Methoden der Klasse, die ich übrigens Generic Object Handler, kurz GenericObjHandler getauft habe, ohne große Erläuterungen vorstellen:</p>
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">object</span> GetProperty(<span style="color: #0000ff;">object</span> classObject, <span style="color: #0000ff;">string</span> propertyName)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> InitializeExceptionProperties();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">try</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> PropertyInfo property = classObject.GetType().GetProperty(propertyName);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">if</span> (property.CanRead)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> LastReturnValue = property.GetValue(classObject, <span style="color: #0000ff;">null</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">catch</span> (Exception ex)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> InitializeExceptionProperties(ex);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> LastReturnValue;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">bool</span> SetProperty(<span style="color: #0000ff;">object</span> classObject, <span style="color: #0000ff;">string</span> propertyName, <span style="color: #0000ff;">object</span> propertyValue)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">{</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">try</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> PropertyInfo property = classObject.GetType().GetProperty(propertyName);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">if</span> (property.CanWrite)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> property.SetValue(classObject, propertyValue, <span style="color: #0000ff;">null</span>);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">catch</span> (Exception ex)</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> {</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> InitializeExceptionProperties(ex);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> }</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span>;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">}</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>
</div>
</div>


 </p>


Nur so viel vielleicht: Neben Methoden kann man über Reflection natürlich auch auf Eigenschaften zugreifen. Sogar private Variablen und Anderes sind möglich. Für Eigenschaften wird die PropertyInfo anhand des Namens ermittelt, geprüft ob diese gelesen oder geändert werden kann, und dies dann entsprechend mit GetValue() oder SetValue() durchgeführt.</p>


 </p>
<h3>Aufruf aus Dynamics NAV C/AL</h3>


Und wie wird diese Klasse nun benutzt? Dazu habe ich folgende, eigentlich selbsterklärende Codeunit geschrieben. Diese dient primär dazu, den Aufruf des GenericObjHandler zu kapseln und Methodenaufrufe mit verschiedener Anzahl an Parametern einfacher zu gestalten, so dass nicht zwingend eine generische Liste erzeugt werden muss. Ich möchte nich darauf hinweisen, dass in meinen Tests bei der Nutzung von Variant-Datentypen für DotNet-Variablen einige “Merkwürdigkeiten” auftraten, weswegen ich im angehängten Archiv, die Parameter vorab einer DotNet-Variablen zuweise und diese an die Parameterliste übergebe.</p>
<div id="codeSnippetWrapper" class="csharpcode-wrapper">
<div id="codeSnippet" class="csharpcode">
<div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 200px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="text-decoration: underline;">InvokeMethodParameterList(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;MethodName : Text;Parameters : DotNet <span style="color: #006080;">"System.Collections.Generic.List`1"</span>) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">GenObjHandler := GenObjHandler.Handler();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">GenObjHandler.InvokeMethod(Obj,MethodName,Parameters);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">LastReturnValue := GenObjHandler.LastReturnValue;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">IF GenObjHandler.HasException THEN BEGIN</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> LastErrorText := GenObjHandler.LastMessage;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> EXIT(FALSE);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">END;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">EXIT(TRUE);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="text-decoration: underline;">GetProperty(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;PropertyName : Text;VAR Value : Variant) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">GenObjHandler := GenObjHandler.Handler();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">PropertyValue := GenObjHandler.GetProperty(Obj,PropertyName);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Value := PropertyValue;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">LastReturnValue := GenObjHandler.LastReturnValue;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">LastErrorText := GenObjHandler.LastMessage;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">EXIT(NOT GenObjHandler.HasException);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="text-decoration: underline;">SetProperty(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;PropertyName : Text;Value : Variant) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">GenObjHandler := GenObjHandler.Handler();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">GenObjHandler.SetProperty(Obj,PropertyName,Value);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">LastErrorText := GenObjHandler.LastMessage;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">EXIT(NOT GenObjHandler.HasException);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="text-decoration: underline;">GetLastErrorText() : Text</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">EXIT(LastErrorText);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="text-decoration: underline;">GetLastReturnValue(VAR ReturnValue : Variant)</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">ReturnValue := LastReturnValue;</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="text-decoration: underline;">InvokeMethod(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;MethodName : Text) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Parameters := Parameters.List();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">EXIT(InvokeMethodParameterList(Obj,MethodName,Parameters));</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="text-decoration: underline;">InvokeMethod1(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;MethodName : Text;Parameter1 : Variant) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">Parameters := Parameters.List();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Parameters.Add(Parameter1);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">EXIT(InvokeMethodParameterList(Obj,MethodName,Parameters));</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"><span style="text-decoration: underline;">InvokeMethod2(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;MethodName : Text;Parameter1 : Variant;Parameter2 : Variant) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">Parameters := Parameters.List();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Parameters.Add(Parameter1);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">Parameters.Add(Parameter2);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">EXIT(InvokeMethodParameterList(Obj,MethodName,Parameters));</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="text-decoration: underline;">InvokeMethod3(Obj : DotNet <span style="color: #006080;">"System.Object"</span>;MethodName : Text;Parameter1 : Variant;Parameter2 : Variant;Parameter3 : Variant) : Boolean</span></pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Parameters := Parameters.List();</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">Parameters.Add(Parameter1);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;">Parameters.Add(Parameter2);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">Parameters.Add(Parameter3);</pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"> </pre>

<pre style="overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;">EXIT(InvokeMethodParameterList(Obj,MethodName,Parameters));</pre>
</div>
</div>
</div>
</div>


 </p>


Ich habe einige Beispiele für die Nutzung in eine Codeunit verpackt, möchte hier aber stellvertretend nur zwei Anwendungsfälle zeigen.</p>


</p>


Es gbt jeweils zwei Varianten der Funktionen, eine die eine Ausnahme hervorruft und damit die Verarbeitung abbricht und eine zweite (mit Suffix “TryCatch”), welche über den GenericObjHandler arbeitet und eben nicht abbricht, da die Ausnahme abgefangen wird.</p>


Im ParseXml() geht es um die Validierung einer XML-Datei gegen ein Schema. Hier tritt beim Load() eine XmlException auf. Mit der Implementierung ParseXmlTryCatch() wird diese über den GenericObjHandler abgefangen und der Fehler angezeigt.</p>


Ähnliches gilt für DivisionByZero() und DivisionByZeroTryCatch(). im letzteren Fall wird die Ausnahme angefangen und der entsprechende Fehlertext zurückgegeben.</p>


 </p>
<h3>Installation</h3>


Die Installation ist recht einfach. Laden Sie sich das angehängte Archiv herunter. Dieses enthält</p>
<ul>[*]das Visual Studio 2013 Projekt für die GenericObjHandler-DLL,[*]die Dynamics NAV Codeunits 50011 “Try Catch” und 50010 “Test Try Catch”[*]und 3 Testdateien für die XML-Validierung (TryCatch.xsd, TryCatch_Error.xml, TryCatch_Ok.xml).[/list]

 </p>
<ul>[*]Kopieren Sie, nach der Kompilierung des VS-Projekts, die DLL in die jeweiligen Add-In Verzeichnisse. Für den Dynamics NAV 2013 R2 Server unter C:Program FilesMicrosoft Dynamics NAV71ServiceAdd-ins und den zugehörigen Client unter C:Program Files (x86)Microsoft Dynamics NAV71RoleTailored ClientAdd-ins. Selbstverständlich können Sie auch ein Unterverzeichnis anlegen.[*]Importieren Sie die Objekte aus TryCatch_Objects.txt. Kompilieren Sie diese im Object Designer.[*]Für den Test der XML-Validierung müssen die 3 Dateien TryCatch.xsd, TryCatch_Error.xml und TryCatch_Ok.xml unter C:Temp liegen, Sie können den Pfad aber auch einfach in der Codeunit 50010 anpassen.[/list]

Un nun wünsche Ich Ihnen auch hier viel Spaß bei der Implementierung und beim Testen. Über Feedback und Weiterentwicklungen freue ich mich und werde diese gerne hier zur Verfügung stellen.</p>


 </p>
<h3>Just for fun!</h3>


Zur Feier des Tages noch ein wenig verordneter Spaß </p>


 </p>


</p>


 </p>


Carsten Scholling </p>


Microsoft Dynamics Germany Microsoft Global Business Support (GBS) EMEA</p>


Microsoft Connect: http://connect.microsoft.com Online Support: http://www.microsoft.com/support Sicherheitsupdates: http://www.microsoft.de/sicherheit</p>


Microsoft Deutschland GmbH Konrad-Zuse-Straße 1 D-85716 Unterschleißheim http://www.microsoft.de</p><div style="clear:both;"></div>Далее
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:56.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.