Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

SEHException in sandbox

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

  • bwilliamson266 Profile Picture
    bwilliamson266 10 on at
    RE: SEHException in sandbox

    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.

  • Eric benco Profile Picture
    Eric benco 320 on at
    RE: SEHException in sandbox

    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"

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SEHException in sandbox

    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...

  • Suggested answer
    PranavShroti Profile Picture
    PranavShroti 4,510 on at
    RE: SEHException in sandbox

    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

  • _Lars_ Profile Picture
    _Lars_ 225 on at
    RE: SEHException in sandbox

    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.

  • _Lars_ Profile Picture
    _Lars_ 225 on at
    RE: SEHException in sandbox

    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.

  • PranavShroti Profile Picture
    PranavShroti 4,510 on at
    RE: SEHException in sandbox

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans