Wednesday, 18 January 2023
  1 Replies
  3.4K Visits
0
Votes
Undo
Hi,

I am trying to save document in Engineering base by external application using Aucotec.Engineering.Interop and getting the Unable to cast exception.
Below is my code and also attached the error screenshot please refer to attachment and help me to solve the issue.

Thank you in advance

static void Main(string[] args)
{
Application application = new Application();
if (application == null)
{
Console.WriteLine("Engineering base client is not running !!";);
Console.ReadKey();
return;
}

var currectObj = application.Selection.Item(1);
if (currectObj != null)
{
var path = "pd2pid.xml";
var documnetEBML = currectObj.NewChild(AucObjectKind.aucObjDocument, AucType.aucDocumentBlob);
documnetEBML.Attributes.Add(AucAttribute.aucAttrDesignation, Path.GetFileName(path));
IAucExternalDocument ex = (IAucExternalDocument)(documnetEBML);
ex.AttachFile(path);
ex.Store();
documnetEBML.Store();
}
}

Regards,
Pushpendra Kumar
Haldor Topsoe
3 years ago
·
#1878
0
Votes
Undo
hi,
I think you should get this EB example in this way:
Maybe we can try:)

ApplicationClass ebApp = new ApplicationClass();
IAucApplication application = ebApp.Application;

instead of

Application application = new Application();
  • Page :
  • 1
There are no replies made for this post yet.