[ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("FunctionalError")] [ComVisible(true)] [Guid("0476fd84-061f-4b17-a1c0-c39c1ed2d5d1")] public class FunctionalError { /// <summary>Code of the error</summary> public int ErrorCode { get; internal set; } /// <summary>Description of the error code</summary> public string ErrorType { get; internal set; } /// <summary>The message describing what went wrong on the server side</summary> public string ErrorReason { get; internal set; } /// <summary>The location where the error occured on the server side</summary> public string ErrorLocation { get; internal set; } /// <summary>The OriginalAttributeValue for the error.</summary> public string OriginalAttributeValue { get; internal set; } }
Comments
Could you try making all properties public instead of the setters internal? They are called with reflection and with a series of binding flags.
Software Design Engineer II
Dynamics NAV Office 365
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Since the getters are public, it shouldn't make a difference.
I also tried renaming the property to "FuncErrorCode", in case "ErrorCode" is some sort of reserved word, but that doesn't help either.
I also tried making it a string instead of integer, but it doesn't help.
I have lots of other classes in my automation dll which are used in the code before the error occurs. And they all work fine.
Only difference I see is that this class instance is returned by a property of another class, which comes from a collection that is a property on another class and this last one is returned by a method, see explanation below. So what I mean is that the class is not instantiated in NAV with the create statement, it is created in the .NET code and returned in a subproperty of the return value of a method.
So: there is an automation class which has a method Send815Request, this method returns an automation class instance of type IE815Response Then the class IE815Response has a property called WSErrorDetails of type WSErrorDetails: This WsErrorDetails class has a property FunctionalErrorCollection of type FunctionalErrorCollection: And in the class FunctionalErrorCollection there is an indexer for retrieving the FunctionalError instances that have the problem:
The C/AL code tested first if the FunctionalErrorCollection was empty by testing if count > 0; this generated true, which is correct because there was one object in the collection. Next the object was retrieved using item(0). Although this works fine in the classic client, the RTC code doesn't seem to do this correct, I saw that using the Visual Studio debugger on the generated C# code. Therefore, all properties of the incorrectly retrieved object from the collection generated errors.
In the .NET code, I modified my FunctionalErrorCollection so that it no longer inherits from ArrayList and I replaced the indexer with:
Now it works like a charm.
This is a bug in the RTC code though, the ArrayList with indexer should work!