Doc.save method overload error

Or no its here atcually.
DataSet dS = templateController.RetrieveFormData(int.Parse(session.GetSessionValue(SessionKeys.CaseId)), tailoredResponseList);

@vlbuch23
If your application’s target framework is .NET 4.5.2, you should use Aspose.Words .NET4.0 AuthenticodeSigned dll.

Yes, as I mentioned in my previous answer, according to your stack trace the exception occurs while parsing string to integer.

Hi,
Ok I have new error now. I have updated as per what you provided. And also doctype in database is just the doc type with extension .pdf or .doc.

Retrieve form code has not been changed so if it was working before why would not it now.

System.IO.MemoryStream objstream = new MemoryStream(LetterTemplateEntity.CRSC_LETTER_TEMPLATE);
doc = TemplateEngine.ExecuteDocumentMerge(objstream, dS);
                    
string doctype = LookupService.Instance.RetrieveLookupTableDescription(LookupTables.LK_DOCUMENT_TYPE,
Util.ConvertToInt(LetterTemplateEntity.DOCUMENT_TYPE_ID.ToString()));

I have code as below : -

Response.Clear();

//doc.Save(LetterTemplateEntity.CRSC_LETTER_TEMPLATE_DESC + doctype,
//   SaveFormat.FormatDocument, SaveType.OpenInBrowser, this.Response);
doc.Save(this.Response, "LetterTemplateEntity.CRSC_LETTER_TEMPLATE_DESC + doctype", Aspose.Words.ContentDisposition.Attachment, new OoxmlSaveOptions());

Response.AddHeader("Content-Disposition", "attachment; filename=" + LetterTemplateEntity.CRSC_LETTER_TEMPLATE_DESC + doctype);
Response.End();

Error

----------Start Logging-------------

Error Number: 3c66fcdb-0ac4-4935-b2fd-ef2cfca67ee8
 User: surbhi.shah
 Error: System.IndexOutOfRangeException: There is no row at position 0.
   at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
   at System.Data.DataRowCollection.get_Item(Int32 index)
   at SCORB.BusinessLogic.TemplateController.RetrieveFormData(Int32 caseId, String TailoredReponseList) in C:\Source\crsc-source-code-with-new-code-master\SCORB.BusinessLogic\Controllers\TemplateController.cs:line 120
   at CRSC_Notifications_GenerateNotificationLetters.GenerateNotificationLetter_Click(Object sender, EventArgs e) in C:\Source\crsc-source-code-with-new-code-master\CORB.Web\CRSC\Notifications\GenerateNotificationLetters.aspx.cs:line 185

----------End Logging-------------

Any help on how to solve please let me know. Notice that old method which was working before with old dll I have commented. That string error went away when I changed the filename. I am sure something to do with this method.
It saves in history table but not able download via browser still.

@vlbuch23 Regarding your code, Response.AddHeader line of code is not required, because this is already done inside Document.Save method implementation.
Regarding the error message, again, it is not related to Aspose.Words. It occurs in TemplateController.cs line 120, in this line of code DT.Rows[0]. It means that there are no rows in DT.Rows.

I checked. But here I dont noticed anything. Even database table I logged on and checked.

private DataTable RetrieveTailoredReponseList(string TailoredReponseList)
{
    DataTable tailoredResponseList = new DataTable("TailoredResponseList");
    using (SCORBEntities context = new SCORBEntities())
    {
        if (TailoredReponseList != "")
        {
            string sqlQuery = "SELECT CRSC_TAILORED_RESPONSE_DESC AS CrscTailoredResponseDesc FROM LK_CRSC_TAILORED_RESPONSE WHERE ";
            int sqlLength = sqlQuery.Length;

            foreach (string id in TailoredReponseList.Split(','))
            {
                if (id != "")
                {
                    sqlQuery += "CRSC_TAILORED_RESPONSE_ID = " + id + " Or ";
                }
            }
            if (sqlQuery.Length > sqlLength)
            {
                //remove last Or and get data
                sqlQuery = sqlQuery.Remove(sqlQuery.Length - 4);
                //get table and return it
                //DataTable tailoredResponseList = Util.GetDataTableFromSqlStatement(sqlQuery); //DM
                tailoredResponseList = Util.GetDataTableFromSqlStatement(sqlQuery);
                tailoredResponseList.TableName = "TailoredResponseList";
                return tailoredResponseList;

            }
        }
        //return null; //DM
        return tailoredResponseList;
    }

@vlbuch23 Most likely the returned DataTable is empty and does not have rows. Please make sure the DataTable is not empty. The problem must be sitting somewhere in your data access layer.

Yes one of the tables is empty for TBL_NOTIFICATION_HISTORY. I will have to add something to it and then should work otherwise.?

Thats no help. Infact it reads from the database in the app I saw but not able to download anything. Not sure why .

@vlbuch23 Unfortunately, it is difficult to say what the problem is without ability to reproduce the problem. Could you please create a simple application example that will allow to reproduce the problem? We will check it and provide you more information.
For now, all error messages posted by you are not related to Aspose.Words. So most likely Aspose.Words is not the reason of the problem. Since you are in better position to debug your application, you can check whether Aspose.Words related code is executed at all by your application. According to the error messages you have posted it looks like the application crashes before executing Aspose.Words elated code.

Hello

In that case of all what I tried and spent time on it researching I would like to keep old binary and just replace the subscription file on the server

Let me know if that’s doable because it seems like this code breaks so easily as well.

Thanks
Surbhi

@surbhiksnkariya82 New license file might not work with old version of the product. If you already have a license for Aspose.Words, it means you have a 1-year subscription for free upgrades to any new Aspose.Words version that comes out. Any Aspose.Words version released before the subscription expiry date - you can just download and use it unlimited time.

Ok I am a bit confused

I have aspose words 19.5.0.0 something on server and i it had subscription but recently the govnerment renewed

So can I not replace license file and continue using old binary which also had subscription

Thanks
Surbhi

@surbhiksnkariya82 Yes, you can use old product with old license file.
The subscription entitles you to software updates for a year. Please see Purchase FAQ for more information.

Ok but if we renew the old product with old binary will that be ok as well to do ? If you notice under my purchase there are two subscriptions

@surbhiksnkariya82 If the version of Aspose.Words was released before the expiration date in your license you can use this version with your license. You can check when your license subscription expires by opening the license file in Notepad (but take care not to modify and save the license file or it will no longer work) and see the SubscriptionExpiry field.

<SubscriptionExpiry>20220218</SubscriptionExpiry>

It means that you can free upgrade to version of Aspose.Words published before 02/18/2022.

This can be marked as completed. I am able to do it as needed. Was a lot more than I thought.

@vlbuch23 It is perfect that you managed to resolve the problems on your side. Please feel free to ask in case of any issues. We will be glad to help you.

Hello Alexey,

Only one glitch I have found is that I get Word Document Corrupt error and why would that be the case.
When I click save and ok it does open but it would be nice for the customer see that message.

Thanks
Surbhi

@vlbuch23 Could you please attach the document which causes Document Corrupt error? We will check the issue and provide you more information.

@vlbuch23 You should add Response.End right after saving document to response to resolve this problem. See the following code:

doc.Save(Response, "test.docx", ContentDisposition.Attachment, new OoxmlSaveOptions());
Response.End();