Skip to main content

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.Propertiesr"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";
}
}
}
}

 

Good day,


 


Please see below community posts where users had similar error message with you hopefully they will help resolve yours.


 


http://community.k2.com/t5/K2-blackpearl/Could-not-load-file-or-assembly-SourceCode-HostClientAPI-or-one/ta-p/93089


http://community.k2.com/t5/K2-blackpearl/Could-not-load-file-or-assembly-SourceCode-HostClientAPI-or-one/ta-p/93356


http://community.k2.com/t5/K2-blackpearl/Could-not-load-file-or-assembly-SourceCode-HostClientAPI-Custom/m-p/76566#M22262


 


Kind regards


Themba


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


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


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


Reply