Skip to main content
Nintex Community Menu Bar

Error preview document

  • May 21, 2018
  • 4 replies
  • 15 views

Hi

 

I'm using code in an ASP.NET web form project to preview documents, but I get an error when running the code in google chrome;

 

Could not load file or assembly 'SourceCode.HostClientAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

 

Please help.

 

See code below;

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SourceCode.SmartObjects.Client;
using SourceCode.Hosting.Client.BaseAPI;

namespace testwebapp
{
public partial class Preview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SmartObject smartObject = new SmartObject();
SmartProperty fileMemo = smartObject.Properties["AttachementFile"];

// read the return properties of the SmartObject
if (fileMemo.Value != null)
{

var doc = new System.Xml.XmlDocument();
doc.LoadXml(fileMemo.Value);
var fileAsBase64 = doc.SelectSingleNode("/file/content").InnerText;
byte[] data = Convert.FromBase64String(fileAsBase64);

Response.ClearContent();
Response.OutputStream.Write(data, 0, data.Length);
Response.Flush();
Response.ContentType = "application/pdf";
}
}
}
}

 

4 replies

  • May 21, 2018

  • Author
  • May 21, 2018

Thanks Themba

 

Visual Studio/IIS and the dll are now on 64 bit, but still getting the following error;

 

An exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in SourceCode.SmartObjects.Client.dll but was not handled in user code


  • May 21, 2018

Good day,


 


Please see below with  information regarding Uploading files to a SmartObject File property: https://help.k2.com/onlinehelp/k2blackpearl/devref/4.7/default.htm#working_with_smartobjects_updload_file.html


 


hopefully this documentation will be helpfull.


 


Kind regards


  • Author
  • May 21, 2018

Hi

 

Thanks for your feedback and attached link.

 

Please note that what I'm  actually trying to do is download the file so that I can preview on a SmartForm.

 

Cheers