I'm developing an AutoCAD plugin for my application. I'm using AutoCAD 2012. Plugin opens .NET named pipe, and so I can connect to it from my desktop application very easily.
First of all, i have created an interface. Here it is
[ServiceContract]
public interface IConnector
{
[OperationContract]
[FaultContract(typeof(Exception))]
void GetPdfVersion(string filePath, string exportFilePath);
}
My AutoCAD plugin derived from IExtensionApplication interface, so on Initialize method i've written this
this.host = new ServiceHost(typeof(Printer), new[] { new Uri("net.pipe://localhost") });
this.host.AddServiceEndpoint(typeof(IConnector), new NetNamedPipeBinding(), "GetPdfVersion");
this.host.Open();
In one of functions, I need to open document and process it. So, I have written folowing code
var docColl = Application.DocumentManager;
Document curDraw = null;
try
{
if (File.Exists(@"d:\1.dwg"))
{
curDraw = docColl.Open(@"d:\1.dwg", true, string.Empty);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
But it throws a COM exception, on the curDraw = docColl.Open(@"d:\1.dwg", true, string.Empty);
code, with HRESULT=-2147418113
I need Document object for processing the dwg file. Is there any possible ways to fix that error?