Getting a COMException when calling MyApplicationClass.Quit()

B

boomshanka

I have a visio document from which I wish to modify all shapes and export
pages to HTML. Here is a rough view of the code:

ApplicationClass visioApplication = new ApplicationClass();
short flags = (short)VisOpenSaveArgs.visOpenHidden +
(short)VisOpenSaveArgs.visOpenRW;
Document activeDocument = null;

try
{
Document visioDocument =
visioApplication.Documents.OpenEx(visioFilePath, flags);
activeDocument = visioApplication.ActiveDocument;
int numberOfPages = activeDocument.Pages.Count;
if (numberOfPages > 0)
{
for (int i = 1; i <= numberOfPages; i++)
{
Page page = activeDocument.Pages;
int numberOfShapes = page.Shapes.Count;
for (int j = 1; j <= numberOfShapes; j++)
{
foreach (Hyperlink hyperLink in shape.Hyperlinks)
{
hyperLink.Delete();
}
shape.AddHyperlink();
shape.Hyperlink.Address = myHyperLinkAddress;
string savedFillStyle = shape.FillStyle;
shape.FillStyle = highlightedFillColor;
page.Export(destinationfilePath);
shape.FillStyle = savedFillStyle;
}
page.Export(filePath);
}
}
else
{
Console.WriteLine(string.Format("The document '{0}' did not contain
any pages", activeDocument.Name));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
short savedAlertResponse = visioApplication.AlertResponse;
visioApplication.AlertResponse = 7;
activeDocument.Close();
visioApplication.AlertResponse = savedAlertResponse;
visioApplication.Quit();
}

Note that a few parameters are not declared but they are irrelevant in this
case. If I omit the HyperLink and FillStyle modification, my console
application runs fine, but if I include the modification I receive the
following error when I call Quit():

COMException: {"The remote procedure call failed. (Exception from HRESULT:
0x800706BE)"}
ErrorCode: -2147023170
TargetSite: {Void Quit()}

I'm using "Visio 2007 12.0.6504.5000 SP2 MSO (12.0.6425.1000)" and I have
not been able to track down the cause of the error. Does anyone have a clue
as to what the cause might be?
 
Y

Yossi.M

Hi,
I also have the same problem. My application runs on Windows 2008 SP2 32Bit.
On what platform does your application run on ?
I noticed that when I run my application on Windows 2003 R2 SP2 32Bit the
application runs OK with no error.
With regards,
Yossi
 
B

boomshanka

Hi Yossi,

Sorry for the long wait but I've been working around the problem until I
found this post again. This application runs on Windows Server 2008 SP2 64bit
with Visio 2007 installed.

As I mentioned before I never found a solution to the problem - sorry.

Yossi.M said:
Hi,
I also have the same problem. My application runs on Windows 2008 SP2 32Bit.
On what platform does your application run on ?
I noticed that when I run my application on Windows 2003 R2 SP2 32Bit the
application runs OK with no error.
With regards,
Yossi

boomshanka said:
I have a visio document from which I wish to modify all shapes and export
pages to HTML. Here is a rough view of the code:

ApplicationClass visioApplication = new ApplicationClass();
short flags = (short)VisOpenSaveArgs.visOpenHidden +
(short)VisOpenSaveArgs.visOpenRW;
Document activeDocument = null;

try
{
Document visioDocument =
visioApplication.Documents.OpenEx(visioFilePath, flags);
activeDocument = visioApplication.ActiveDocument;
int numberOfPages = activeDocument.Pages.Count;
if (numberOfPages > 0)
{
for (int i = 1; i <= numberOfPages; i++)
{
Page page = activeDocument.Pages;
int numberOfShapes = page.Shapes.Count;
for (int j = 1; j <= numberOfShapes; j++)
{
foreach (Hyperlink hyperLink in shape.Hyperlinks)
{
hyperLink.Delete();
}
shape.AddHyperlink();
shape.Hyperlink.Address = myHyperLinkAddress;
string savedFillStyle = shape.FillStyle;
shape.FillStyle = highlightedFillColor;
page.Export(destinationfilePath);
shape.FillStyle = savedFillStyle;
}
page.Export(filePath);
}
}
else
{
Console.WriteLine(string.Format("The document '{0}' did not contain
any pages", activeDocument.Name));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
short savedAlertResponse = visioApplication.AlertResponse;
visioApplication.AlertResponse = 7;
activeDocument.Close();
visioApplication.AlertResponse = savedAlertResponse;
visioApplication.Quit();
}

Note that a few parameters are not declared but they are irrelevant in this
case. If I omit the HyperLink and FillStyle modification, my console
application runs fine, but if I include the modification I receive the
following error when I call Quit():

COMException: {"The remote procedure call failed. (Exception from HRESULT:
0x800706BE)"}
ErrorCode: -2147023170
TargetSite: {Void Quit()}

I'm using "Visio 2007 12.0.6504.5000 SP2 MSO (12.0.6425.1000)" and I have
not been able to track down the cause of the error. Does anyone have a clue
as to what the cause might be?
 
Top