Hoppa till huvudinnehållet

Using FeatureSet in C# script

Kommentarer

2 kommentarer

  • Arjan Wilkens
    I suspect that the featureset created at the server cannot be sent to the client, as it cannot be serialized.

     

    C# script activity is a server side activity. If you want to use a client side object such as a featureset then the object must be serialized (https://en.wikipedia.org/wiki/Serialization) to a datastream This object must have a serialization attribute ('marked') in order to allow this to happen. And, as the error message states, a featureset (an object defined by esri code) does not have this attribute.

     

    If you do not need the FeatureSet itself  when the code in the C# script activity is completed, then actively destroy the object by setting it to null in the code. For example, in the small snippet below, the created FeatureSet is written to a json string before the FeatureSet itself is set to null. As a string object is marked as serializable, it can be passed back to the client side of the workflow and used there to re-instantiate the featureset geometries. fstest = new FeatureSet(string1); test = fstest.ToJson(); fstest = null;

     

     
    0
  • Permanently deleted user
    Hi Darko,

     

    Arjan is correct.  This issue is not that the class cannot be used by the script activity, it is due to the transfer of state from server to client.

     

    We do not recommend using the C# Script or VB Script activities for anything beyond proof-of-concept tests or development.  In production, please convert your activities to use native Invoke Method and Assign activities, or compile a custom assembly to do your owrk.  The Script activities will consume memory and files every time they are loaded and we have no way to recover; evenutally the app pool will crash.

     

    Regards,

     

    -Malcolm
    0

Du måste logga in om du vill lämna en kommentar.