Using Interop.Illustrator with VS2017 aand C# PlaceItem.File property throwing exception
C# code as example of problem:
private void Run_OnCLick(object sender, RoutedEventArgs e)
{
Document doc = null;
Illustrator.Application app = null;
try
{
// open AI, init
app = new Illustrator.Application();
// open doc
doc = app.Open("D:\\Test\\Vintage\\Package_Test.ait", Illustrator.AiDocumentColorSpace.aiDocumentRGBColor, null);
// insert image
PlacedItem img = doc.PlacedItems.Add();
int cnt = doc.PlacedItems.Count;
String file = "D:\\Dev\\Vinatage\\00_Coaster.png";
img.File = file; //throw exception
img.Top = 0;
img.Left = 0;
img.Height = 5.4;
img.Width = 5.4;
}
catch (COMException ce)
{
string msg = ce.StackTrace;
string errorCode = String.Format("0x{0:X}", ce.HResult);
MessageBoxResult result = MessageBox.Show(msg, ce.Source, MessageBoxButton.OK, MessageBoxImage.Error);
}
finally
{
doc.Close(AiSaveOptions.aiDoNotSaveChanges);
app.Quit();
}
}
msg =
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Illustrator.PlacedItem.set_File(String )
at WpfApplication1.MainWindow.Run_OnCLick(Object sender, RoutedEventArgs e) in D:\projects\WpfApplication1\WpfApplication1\MainWindow.xaml.cs:line 46
I am hoping someone has an idea what is causing this.
If I use the AI menu File->Place it works fine ...
