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);
wordDoc.Save("ReplacedSample.docx");
wordDoc.Close();

Greetings

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.
http://help.syncfusion.com/ug/asp.net%20mvc/index.html#!Documents/find.htm

http://help.syncfusion.com/ug/asp.net%20mvc/index.html#!Documents/replace.htm
Please refer the below mentioned online sample link to know more usage on find and replace technique using DocIO.
Online sample link:
http://asp.syncfusion.com/demos/web/docio/replacewithformating.aspx

Please let us know if you have any questions.
Regards
Sivasubramani.v

Loader.
Live Chat Icon For mobile
Up arrow icon