When you reference a .NET class that exposes events, and you switch on the WithEvents property, C/SIDE creates the event triggers for you. If you later want to update the reference to the .NET class, for whatever reason (like, there is a newer version of the assembly), updating the reference will actually delete the event triggers with all the code in them.
To be fair to this non-feature, at least it warns you politely:
This is not something you experience once in a geologic era. When you are developing your own assemblies, this will happen fairly often – as often as you add or remove events to/from your classes, and you want to reflect that in the Development Environment. Or as often as you increase the version of your assembly.
Unfortunately, there is no way in the Development Environment to update the reference while actually retaining the event triggers or code in them.
But still, there is a way, and a fairly easy way at that.
Continue reading How To Update a Class Or Assembly Reference in C/AL And Retain Event Trigger Code
And yes, I almost forgot… Somebody (sorry, I didn’t catch the name) asked me to put my life hack on the blog as well, so here it is. For all of you who were not there, I use this as a template for declaring .NET variables – until Microsoft provides means to declare them in a simpler ways. Inline, anyone?
So – download the life hack, or cheat sheet, here: http://vjeko.com/wp-content/uploads/2014/11/Life_Hack_No_1.docx
Thanks to everybody who attended my session today at NAV TechDays 2014 in Antwerp. As promised, here are the goodies from the session. I’ve simply taken the objects and I deliver them here with no explanations or comments – when Luc publishes the sessions and the slide decks on Mibuso, you’ll be able to figure out what’s what. I hope you don’t mind.
I’ve also included my demo from the PRS session today, about the Service Locator pattern. The ZIP file does not include the Visual Studio solution – you can find it in my previous post, that I’ve put here yesterday.
I hope you find these examples useful and that they help you get started with .NET Interop quickly.
Download the files here: http://vjeko.com/wp-content/uploads/2014/11/NAVTechDays2014.MereMortals.zip.
So, NAV TechDays 2014 have started, again, with the pre-conference sessions that were all sold out and packed full.
Today I had an extraordinary pleasure to teach the advanced .NET Interoperability concepts to 15 people that came from all over the world, from Brazil to Australia. It was an interesting workshop, challenging – I must say (thanks to Rafael who made me improvise a solution to a typical DotNet limitation), and I am looking forward to delivering two more sessions about .NET and Control Add-ins tomorrow, and on Friday.
As promised, I am making the materials from the presentation available for the download, in case you want to learn the same stuff the attendees learned today.
Continue reading NAV TechDays 2014 Pre-conference goodies
You may love C/AL as a language, but there is an area in it that you must just hate. It’s the error handling. Plainly put, and being actually quite positive about it, in NAV, error handling just sucks. If an error happens, it happens. You have only one possibility to actually capture the error, and it’s the IF CODEUNIT.RUN construct, and it’s limited because you can do it only once per transaction, and if you want to do it twice, you must COMMIT your transaction first.
But still, capturing an error is one thing; actually handling it is quite a different thing altogether.
Continue reading Better error handling in NAV 2015