Cannot find object or property. (Exception from HRESULT: 0x80092004)
Problem occur on the following line of code:
DFXCoreAPI.IPXC_Document.WriteToFile(String sDestFileName, IProgressMon pProgress, UInt32 nFlags)
For testing I am using certificate issued by CA with purpose of digital signatures, so there should be no problem with certificate itself. Also, problems does not occur on every machine that I have tested it, just one or two.
Here is the code I am using:
Code: Select all
PXC_Rect signatureRect = new PXC_Rect()
{
left = rect.Value.left,
top = rect.Value.bottom - 1,
right = rect.Value.left + PDF_SIGNATURE_WIDTH,
bottom = rect.Value.top - PDF_SIGNATURE_HEIGHT - 1
};
byte[] certBuffer = cert.RawData;
contextPointer = CertCreateCertificateContext(PKCS_7_OR_X509_ASN_ENCODING, certBuffer, certBuffer.Length);
UnsafeMethods.DeferedDigitalSignEx(doc, contextPointer, PXC_SignDocumentFlags.Sign_TX_Labels | PXC_SignDocumentFlags.Sign_TX_Name | PXC_SignDocumentFlags.Sign_TX_Date, pageNo, signatureRect, SIGN_REASON, SIGN_LOCATION, SIGN_CONTACT_INFO, null);
doc.WriteToFile(targetPath, null, (int)PXC_DocumentWriteFlags.DocWriteFlag_Incremental);
Code: Select all
public static void DeferedDigitalSignEx(IPXC_Document doc, IntPtr pointer, PXC_SignDocumentFlags flags, int pageIndex, PXC_Rect position, string reason, string location, string contact, string imagePath)
{
unsafe
{
_CERT_CONTEXT* contextStructPointer = (_CERT_CONTEXT*)pointer;
doc.DeferedDigitalSign(ref *(contextStructPointer), (uint)flags, (uint)pageIndex, position, reason, location, contact, imagePath);
}
}