I got method which runs some word document report generation.
I tought that there is no way to do it synchronously, so, I decided to make async await
method for that.
But for some resaon Visual Studio outputs this error
Cannot be used across assembly boundaries because it has a generic type parameters that is an embedded interop type
Embed Interop Types
set to false and if I use simple synchronous method its seems okay
Code of functions is here
public Document GenerateReport(AptTemplateType type)
{
try
{
var builder = _curentrBuilderFactory.GetBuilder(type);
var generatedDocument = builder.CreateDocument();
return generatedDocument;
}
catch (Exception e)
{
throw;
}
}
public async Task<Document> GenerateReportAsync(AptTemplateType type)
{
WordDocumentBuilder builder;
try
{
builder = _curentrBuilderFactory.GetBuilder(AptTemplateType.UseCaseModelSurvey);
var generatedDocument = await Task.Run(() => builder.CreateDocument());
return generatedDocument;
}
catch (Exception e)
{
throw;
}
}
UPD:
CreateDocument
simple defenition:
public virtual Document CreateDocument()
{
return WordApplication.Documents.Add(ref OMissing, ref OMissing, ref OMissing, ref OMissing);
}