This post was originally published on this site.

I’m currently building an integration plugin for a customer that uses an online ERP system that has a REST interface to communicate with the system. To use the REST endpoint in an easier way the company has provided me with a couple of connection DLLs.

This is the first time I’m using external DLLs in a plugin for an online deployment, I’ve previously only done that on premise, and it’s a couple of years ago, so this meant that I’m facing some new challenges.
The first issue is that I can’t just place stuff in the assembly folder and look happy, since it’s online everything needs to be located in the database, and well you can’t just put some dlls there so ILMerge is needed to create one dll. At first I was a but curious how the sandbox in Dynamics 365 would react to the external calls that I was going to make but I really didn’t think it would be an issue, and that was a correct assumption, no problems making the calls from the sandbox, one issue out.

The next thing I thought was my salvation is that I’m able to do some testing on an on-premise Dynamics 365 and just setting the plugin to run in the sandbox. This was one issue I didn’t expect. When I ran my code in the sandbox on our server, it was working just fine but when I registered the assembly in Dynamics 365 online I got in trouble, and it’s not really amusing to troubleshoot plugins online. This one was even worse since it was five or so dlls that I had merged using ILMerge, which also was a source of concern. This proved not to be an issue, the dll that was the output from ILMerge was working as planned.

I got a bit of help by George Doubinski  and the issue was that the code I was using implicit typed variables. The reason for this is that I got code examples from the ERP provider. Don’t get me wrong here, I’m not blaming them for that, it just that I’m coming from hardware where everything is explicitly typed so my code is generally explicit typed even though the best practice for C# is to use implicit typed variables. This time however I let it be as the example code was written and since that worked in a sandboxed on-prem I didn’t really think about it.

I’m not sure what it is that makes the dynamic and var problematic here but it was very clear that in this case it did not work online.

The moral of this is that even though you have code that’s working in a sandboxed on-premise installation it might not work in an online deployment. If that happens it might be worth it to start looking at what variable types you’re using. To merge dlls together with ILmerge is working very good though, which is good.

Rickard Norström
Developer at CRM-Konsulterna