Author Topic: About Document.SendStringToExecute()  (Read 494 times)

0 Members and 1 Guest are viewing this topic.

CrockettScience

  • Mosquito
  • Posts: 13
About Document.SendStringToExecute()
« on: June 06, 2019, 12:13:32 PM »
I'm working with a command in C# where we initialize a pack of documents based on certain criteria. It involves a queue of documents being created, edited, and saved. The way we do this is we create the Doc, switch to it, then SendStringToExecute() with a hidden command that does the initializing, saves it to file, then checks the queue to see if there's more and repeats. This way, each document is edited in it's own document context, which we need to do for reasons I can't get into.

It works most of the time, but quite commonly, it crashes at random in such a way that isn't reproducible. After some testing, the problem seems to go away when the second boolean argument of SendStringToExecute(), that is, wrapUpInactiveDoc, is set to true. However, the only problem there is then SendStringToExecute() throws an eInvalidInput error every time it's called, and then crashes when all the commands are complete. The documents end up otherwise unscathed, It's just inconvenient and bad presentation for our clients.

So I want to know, what exactly does wrapUpInactiveDoc = true actually do, why does it throw an eInvalidInput exception, and how can I do this in a way that doesn't throw that error.

dgorsman

  • Water Moccasin
  • Posts: 2400
Re: About Document.SendStringToExecute()
« Reply #1 on: June 06, 2019, 07:50:32 PM »
Backing up a step... how many drawings are we talking about?  Dozens?  Hundreds?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

CrockettScience

  • Mosquito
  • Posts: 13
Re: About Document.SendStringToExecute()
« Reply #2 on: June 07, 2019, 11:39:32 AM »
At most, it could possibly be 1 or 2 dozens. Or only a handful. It really depends on the project.

But let's assume worst case scenario for the sake of stability. Is it possible to have too many?

CrockettScience

  • Mosquito
  • Posts: 13
Re: About Document.SendStringToExecute()
« Reply #3 on: June 07, 2019, 01:00:46 PM »
Hmm, it seems as though the problem is unchanged even when I close each document after I'm done with it.

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1365
  • class keyThumper<T>:ILazy<T>
Re: About Document.SendStringToExecute()
« Reply #4 on: June 08, 2019, 07:04:05 PM »
Is the Save done in your code or by code dependant on the SendString ?
I s'pose my real question is how complex is the command you are passing ?

I recall reading 'somewhere' recommendations about the use of wrapUpInactiveDoc, but sorry, age is affecting my memory.

added afterthought :
Are you doing the Save inside a transaction Scope ?
« Last Edit: June 08, 2019, 07:17:47 PM by kdub »
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

CrockettScience

  • Mosquito
  • Posts: 13
Re: About Document.SendStringToExecute()
« Reply #5 on: June 13, 2019, 02:02:56 PM »
Save is done by the Database method SaveAs(), and after the transaction is closed.

CrockettScience

  • Mosquito
  • Posts: 13
Re: About Document.SendStringToExecute()
« Reply #6 on: June 13, 2019, 05:31:31 PM »
I was finally able to get the crashes to stop by executing the Database method CloseInput(true) on the document before working on another. Don't ask me why  :idiot2: