Quantcast
Channel: Microsoft Dynamics GP Forum - Recent Threads
Viewing all articles
Browse latest Browse all 32807

VS Tools Sdk Addin: Attempted to read or write protected memory

$
0
0

We are currently using GP 10 SP 5.  We have an addin, developed with the VS Tools SDK, attached to the Sales Transaction Entry window.  At random some users report the error: "Attempted to read or write protected memory.  This is often an indication that other memory is corrupt."  In troubleshooting and debugging this I have found that the error is coming from an exception when calling GetFirst() on SopLineWork table in the form.  Most of our CSRs have never seen this error, but a few get this error at least once a day.  I can't find anything different in the GP client install.  It has been happening for at least two years now.

One interesting thing I have seen is that there seems to always be a period of inactivity (10-15 minutes) where the Sales Transaction Entry window was left open.  But, I cannot reproduce the error by idling for 10-15 minutes.

My worry is that the exception is coming from the third party modifications to the Sales Transaction Entry form, but, I can't disable the modifications to have the CSRs test that scenario.  If I did commissions wouldn't be calculated and finance wouldn't be happy.  I could in our test environment, but we haven't really seen this error in the test environment.

Below is approximately the code we are having trouble with. For simplicity and ease f posting I have removed much of the error handling and made it more generic.  Does anyone have any ideas on how to further troubleshoot or solve this issue?

Thank you,

Paul

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Dexterity.Bridge; using Microsoft.Dexterity.Applications; using Microsoft.Dexterity.Shell; using Microsoft.Dexterity.Applications.DynamicsDictionary; class FreightUtil { #region Static references to GP Forms and Windows // Create a reference to the Sales Transaction Entry form static Microsoft.Dexterity.Applications.TheEthoSeriesModifiedDictionary.SopEntryForm SOPEntryForm = TheEthoSeriesModified.Forms.SopEntry; // Create a reference to the Sales Transaction Entry window static Microsoft.Dexterity.Applications.TheEthoSeriesModifiedDictionary.SopEntryForm.SopEntryWindow SOPEntryWindow = SOPEntryForm.SopEntry; #endregion public static void SaveFreight(string strShippingMethod, double numFreightCharge) { SOPEntryWindow.LocalOriginatingFreightAmount.Value = numFreightCharge; // Force the validation of the new freight amount SOPEntryWindow.LocalOriginatingFreightAmount.RunValidate(); SOPEntryWindow.LocalOriginatingFreightAmount.ForceValidate(true); TableError te = TableError.NoError; //don't attempt to access selectedRow after this point, it may be null after the tables have been updated. if (strShippingMethod != SOPEntryForm.Tables.SopHdrWork.ShippingMethod.Value) { if (te == TableError.NoError || te == TableError.DoubleLock) { SOPEntryForm.Tables.SopHdrWork.ShippingMethod.Value = newShippingMethod; } else { throw new Exception("An error occurred... Error: " + te.ToString()); } GPShippingMethod = strShippingMethod; } te = TableError.NoError; //check all the items to make sure they have the correct shipping method te = SOPEntryForm.Tables.SopLineWork.GetFirst(); //<-- error occurrs here if (te == TableError.NoError) //there may not be any items { do { if (SOPEntryForm.Tables.SopLineWork.ShippingMethod.Value != newShippingMethod) { te = SOPEntryForm.Tables.SopLineWork.Change(); if (te == TableError.NoError) { SOPEntryForm.Tables.SopLineWork.ShippingMethod.Value = newShippingMethod; te = SOPEntryForm.Tables.SopLineWork.Save(); } } te = SOPEntryForm.Tables.SopLineWork.GetNext(); } while (te == TableError.NoError); } } }


Viewing all articles
Browse latest Browse all 32807

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>