We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

NullReferenceException when trying to replace more then 10 chars

When I try to replace a string in a word document larger then 9 chars + closing char I assume,
I get, on closing the document, a NullReferenceException.

When replacing a string with 8 chars with a big string it doesnt give me this exception.

Is this normal and is there a way to work around this?

strToReplace = "ReplaceReplace" + (i).ToString(); // this gives me a problem
strToReplaceWith = "HelloWorldasodifhaldfihasdlifhaldigh" + (i).ToString(); //this doesnt
wordDoc.Replace(strToReplace, strToReplaceWith, true, true);


Attachment: SyncBigReplace_8e2c9e60.rar

2 Replies

MV Mark Visschers June 6, 2015 10:58 AM UTC

For some reason, when I started the program this morning it magically worked...
If this changes and I can create it in a reproducible way ill update this thread.

SV Sivasubramani V Syncfusion Team June 8, 2015 06:06 AM UTC

Hi Mark,
Thank you for using Syncfusion products.
We will wait until we hear from you.
Please refer the below mentioned UG link for more details on find and replace technique in DocIO.

Please refer the below mentioned online sample link to know more usage on find and replace technique using DocIO.
Online sample link:

Please let us know if you have any questions.

Live Chat Icon For mobile
Up arrow icon