I am writing a c# interop (not an addin) program that needs a ‘copy parallel’ function.

I am writing an Microstation Interop program that needs a copy parallel capability.

I have tried the folling code:

private void btnDoIt_Click(object sender, EventArgs e)
      {
          CopyParallel();
      }
 
 
      private void CopyParallel()
      {
          int outE = 0;
          BIM.ElementEnumerator ee = activeModelReference.GetSelectedElements();
          ee.MoveNext();
          int inE = ee.Current.MdlElementDescrP(false);
          BIM.Point3d p = uStaApp.Point3dZero();
          double distance = 20;
          BIM.Point3d plane = new BIM.Point3d();
          plane.X = 0;
          plane.Y = 0;
          plane.Z = 1;
          mdlElmdscr_copyParallel(ref outE, inE, ref p, distance, ref plane);
      }
 
      [DllImport(@"C:\Program Files (x86)\Bentley\MicroStation V8i (SELECTseries)\MicroStation\stdmdlbltin.dll", CallingConvention = CallingConvention.Cdecl)]
      public static extern int mdlElmdscr_copyParallel
          (ref int outElement,
          int inElement,
          ref BIM.Point3d p,
          double distance,
          ref BIM.Point3d plane);

****************************************************
When I run the program I get an exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Question is how to call the mdlElmdscr_copyParallel from the interop program.