"Call to member ErrorCode failed" error in RTC Automation
veerleverbr
Member Posts: 7
I have an automation class Functional Error which is defined as
I have another automation class which, in case of an error, returns an instance of this class. When trying to get the ErrorCode from it in RTC, I get the error:
The message is for C/AL programmers: The call to member ErrorCode failed. Method "Microsoft.Dynamics.Nav.Runtime.NavAutomation.ErrorCode" not found.
I found some similar error messages, but they are all about automation variables of special types like enum, datetime, currency. But this is a simple integer. I don't understand why RTC cannot find it.
Any idea's?
[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; }
}
I have another automation class which, in case of an error, returns an instance of this class. When trying to get the ErrorCode from it in RTC, I get the error:
The message is for C/AL programmers: The call to member ErrorCode failed. Method "Microsoft.Dynamics.Nav.Runtime.NavAutomation.ErrorCode" not found.
I found some similar error messages, but they are all about automation variables of special types like enum, datetime, currency. But this is a simple integer. I don't understand why RTC cannot find it.
Any idea's?
0
Comments
-
Are you sure that you are having the right class at hand? If you compile it your self - it could be a little out of date. So verify dates.
Could you try making all properties public instead of the setters internal? They are called with reflection and with a series of binding flags.Eric Beran
Software Design Engineer II
Dynamics NAV Office 365
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.0 -
Well, I tried making the setters public, but it makes no difference.
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 IE815Responsepublic IE815Response Send815Request(IE815Request request) { ... }Then the class IE815Response has a property called WSErrorDetails of type WSErrorDetails:public WsErrorDetails WSErrorDetails { get; set; }This WsErrorDetails class has a property FunctionalErrorCollection of type FunctionalErrorCollection:public FunctionalErrorCollection FunctionalErrorCollection { get; set; }And in the class FunctionalErrorCollection there is an indexer for retrieving the FunctionalError instances that have the problem:new public FunctionalError this[int index] { get { return (FunctionalError)base[index]; } set { base[index] = value; } }0 -
I found 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:List<FunctionalError> _list = new List<FunctionalError>(); public FunctionalError Item(int index) { if (index >= 0 && index < _list.Count) { return _list[index]; } return null; } public int Count { get { return _list.Count; } }
Now it works like a charm.
This is a bug in the RTC code though, the ArrayList with indexer should work!0
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