web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

SEHException in sandbox

(0) ShareShare
ReportReport
Posted on by 225

I'm currently trying to create a custom data provider for virtual entities. My external data source that I'm connected to has spatial data, where the plugin converts these spatial x and y coordinates to latitude and longitude.

But "all the sudden" I'm getting this error from that very same function that converts the values:

System.Runtime.InteropServices.SEHException: External component has thrown an exception.

Usually if something is null, then it simply states that. I've checked the values and they seem to be correct. 

I've changed out the variables but the line that seems to fail (I have tracing up to this line) looks like:

var v = (6399593.62575867 / Math.Pow(1 + (0.00673949674233346 * Math.Pow(Math.Cos(1.03205401949991), 2)), 0.5)) * 0.9996;

This is a part of a bigger equation to convert spatial coordinates to latitude and longitude. In a simple console application it works like it should. 

So this leaves me thinking; are the any limits in the sandbox of an online Dynamics 365 v9?

*This post is locked for comments

I have the same question (0)
  • PranavShroti Profile Picture
    4,510 on at

    When you say it was working earlier and not working now... do you mean v8.2 it was working and now v9.0 its not?

    MS has made some changes to v9.0, TLS 1.2 has been introduced. Please try following and let us know how did it go.

    1. Need to update .Net Framework version 4.6 on all D365 CE front end, backend and SQL server. Below is the table that shows which .Net Framework version supports TLS 1.2.

    .Net 4.6 and above-- TLS 1.2 is supported by default

    .Net 4.5 -- TLS 1.2 is supported (Use before CRM connection) System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    .Net 4.0-- TLS 1.2 is not supported by framework but you can still use it with enum value is server has framework 4.5 or above installed ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

    .Net 3.5 or below-- Was not supported earlier but there is a patch to get it working

    2. (In case you have SQL server) Install cumulative updates on SQL server environment. Below table describes which CU will work:

    SQL Server 2014 -- Cumulative Update 8

    SQL Server 2014 SP1-- Cumulative Update 1

    SQL Server 2012 SP2 -- Cumulative Update 6

    SQL Server 2014 -- Cumulative Update 7

    Regards,

    Pranav

    If found useful, please mark the answer as verified

  • _Lars_ Profile Picture
    225 on at

    Hello Pranav!

    We are using 4.5.2 for this plugin. And I'm pretty sure it worked as is on Tuesday :-). I've since extended the plugin doing other things, but this function that causes the error is pretty much google copy and paste and have worked. Its pretty Math.<x> heavy since it converts spatial x and y to latitude and longitude so my first thought was that I've hit some computation limit - I've run this in a dataset which is ~80 000 big a couple of times now. The error "SEHException: External component has thrown an exception." makes no sense for me.

  • _Lars_ Profile Picture
    225 on at

    I've added som simple code in my plugin:

    tracer.Trace("Test 1");
    Math.Pow(2, 2);

    tracer.Trace("Test 2");
    Math.Abs(-1);

    tracer.Trace("Test 3");
    Math.Cos(Math.PI);

    tracer.Trace("End of test");

    Which produces the following trace:

    Test 1
    Test 2
    Test 3
    (end of trace)

    Trace is missing "End of test" that indicates the next line fails. It crashes with the error System.Runtime.InteropServices.SEHException: External component has thrown an exception.

  • Suggested answer
    PranavShroti Profile Picture
    4,510 on at

    Generally this happens when .Net is not able to catch the exception. [System.Runtime.InteropServices.SEHException]

    Can you check what exception is occurring by looking at the ExternalException.ErrorCode property in stacktrace.

    Regards,

    Pranav

    If found useful, please mark the answer as verified

  • Community Member Profile Picture
    on at

    Did you solve the problem? We have a similar problem with a plugin:

    roughly 1% of the executions result in the same SEHException. We do a lot of Math.<x> (Sin, Cos, Atan2, Sqrt, PI) stuff there to calculate the distance between two geocoordinates. We don't have any call to other libraries there...

  • Eric benco Profile Picture
    320 on at

    Were you ever able to resolve this.  I'm seeing something similar in Custom Workflow Activity that executes Math.Cos.  It fails with the same input about 5% of the time.   If I try to trap the error , the SEHException is obfuscated and I just get a "The plug-in execution failed because no Sandbox Worker processes are currently available"

  • bwilliamson266 Profile Picture
    10 on at

    Getting the same intermittent behavior in a workflow activity built with .Net 4.7.1 on D365 production version 9.1.

    The activity includes a function like this:

    Math.Pow(Math.Sin(dlat / 2D), 2D) + Math.Cos(lat1 * _d2r) * Math.Cos(lat2 * _d2r) * Math.Pow(Math.Sin(dlong / 2D), 2D)

    Very inconsistent behavior.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans