Bad variable type

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
JesseH
User
Posts: 18
Joined: Fri Jul 22, 2016 8:47 pm
Location: TN

Bad variable type

Post by JesseH »

Me again. Hopefully this time it won't be from something ridiculous I did elsewhere in the code.

In my wrapper I have a simple function:

Code: Select all

public IPXC_Document OpenPDF(String sFilePath) 
{
    IPXC_Document pDoc = g_Inst.OpenDocumentFromFile(sFilePath, null);
    return pDoc;
}
This method is successfully called near the beginning to read a big PDF file. The program then breaks it out into several smaller letter packs and saves them to individual PDFs. The user then selects them for editing using their default PDF application. So far this all works fine.

The problem occurs when the files are edited and saved, where a FileSystemWatcher notices the update and the program attempts to rebuild the objects in memory from the file. The above function is called again and now results in the following exception:

Code: Select all

System.Runtime.InteropServices.COMException was unhandled
  HResult=-2147352568
  Message=Bad variable type. (Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE))
  Source=TAMLetterManager
  ErrorCode=-2147352568
  StackTrace:
       at PDFXCoreAPI.IPXC_Inst.OpenDocumentFromFile(String lpszFileName, IPXC_DocAuthCallback pAuthCallback, IProgressMon pProgressMon, UInt32 nFlags, UInt32 nRestrictPerms)
       at TAMLetterManager.PDF_Wrapper.OpenPDF(String sFilePath) in c:\Users\haverjes\Documents\Visual Studio 2012\Projects\TAMLetterHandler\TAMLetterManager\PDF_Wrapper.cs:line 32
       at TAMLetterManager.HCS_LetterPacket.updateFromFile() in c:\Users\haverjes\Documents\Visual Studio 2012\Projects\TAMLetterHandler\TAMLetterManager\HCS_LetterPacket.cs:line 162
       at TAMLetterManager.HCS_LetterManager.onLetterUpdate(Object source, FileSystemEventArgs e) in c:\Users\haverjes\Documents\Visual Studio 2012\Projects\TAMLetterHandler\TAMLetterManager\HCS_LetterManager.cs:line 379
       at System.IO.FileSystemEventHandler.Invoke(Object sender, FileSystemEventArgs e)
       at System.IO.FileSystemWatcher.OnChanged(FileSystemEventArgs e)
       at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
       at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
       at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  InnerException: 
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Bad variable type

Post by Sasha - Tracker Dev Team »

Hello JesseH,

You mean, that the files are being used by some default user PDF application and by the Core API SDK at the same time?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
JesseH
User
Posts: 18
Joined: Fri Jul 22, 2016 8:47 pm
Location: TN

Re: Bad variable type

Post by JesseH »

The two are active at the same time, but they shouldn't be accessing the file concurrently. Does the OpenDocumentFromFile() method not open the file in read mode, or require exclusive access to the file?

Given the lack of a specific file interface I assumed the file was read and released.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Bad variable type

Post by Sasha - Tracker Dev Team »

Hello JesseH,

We need more detailed information of what your program is doing. We open the document with Read\ShareRead flag. If any other program opens it for writing whilst we opened it for reading then we will return an error. Though maybe this is not what is happening here thus we require more info - best would be a small sample illustrating the problem.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
JesseH
User
Posts: 18
Joined: Fri Jul 22, 2016 8:47 pm
Location: TN

Re: Bad variable type

Post by JesseH »

It looks like that is what's happening. I tried having my program wait until the external process exits and it works.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Bad variable type

Post by Sasha - Tracker Dev Team »

Hello JesseH,

Well then, you'll need to figure out the working process of your program so that this won't occur.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply