Visio Service Pack 2 Broke Visio C# addon

J

Josef Meile

Hi,

after installing the service pack 2 for Visio and the Windows XP Security
upgrades
from the 30th November, it broke my C# addon, which uses the Microsoft Visio
11.0 Type Library to catch the events of the visio main application and it
also
contains a form which uses the Microsoft Visio 11.0 Drawing Control.

Just if it matters, I'm using Visual Studio 2003 Version 7.1.3088 and .net
Version 1.1.4322 under Windows XP Service Pack 2. I don't have .net Version
2.0 on my
system.

Now retuning to the topic. At first The Visio Reference was broken, so, I
deleted it
and added it again through the "Add Reference" dialog. But then I got:

C:\[Project Path]\FBooleanExp.cs(9): Namespace '' already contains a
definition for 'Visio'

and the line causing this was:

using Visio = Microsoft.Office.Interop.Visio;

So, I drop it and the message went away. However, now I'm getting:

C:\...\Forms\FBooleanExp.cs(501): The type
'Microsoft.Office.Interop.Visio.Window'
is defined in an assembly that is not referenced. You must add a
reference to
assembly 'Microsoft.Office.Interop.Visio'.

The problem is here:

Visio.Window drawingWindow = (Visio.Window)this.dclVisioDrawing.Window;
---^

I added the Drawing Control by using the form designer. After doing this,
Visual
Studio adds automatically the refferences to AxVisOcx and VisOcx. This is the
declaration of the Drawing Control:

private AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl dclVisioDrawing;

I saw the properties window of each reference and noticed that the NameSpaces
are diferent:

* AxVisOcx
(Name): AxInterop.VisOcx
CopyLocal: True
Culture: 0
Description: Microsoft Visio 11.0 Drawing Control Type Library
Identity: {F1A8DFE4-BC61-48BA-AFDA-96DF10247AF0}\1.0\0\aximp
Path: C:\Documents and Settings\jmeile\My Documents\My Data\[Project
Path]\obj\AxInterop.VisOcx.dll
Runtime Version: [Empty]
Strong Name: False
Type: ActiveX
Version: 1.0

* VisOcx
(Name): Microsoft.Office.Interop.VisOcx
Copy Local: False
Culture: 0
Description: Microsoft Visio 11.0 Drawing Control Type Library
Identity: {F1A8DFE4-BC61-48BA-AFDA-96DF10247AF0}\1.0\0\primary
Path:
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.VisOcx\11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.VisOcx.dll
Runtime Version: [Empty]
Strong Name: True
Type: ActiveX
Version: 1.0

* Visio
(Name): Interop.Visio
Copy Local: True
Culture: 0
Description: Microsoft Visio 11.0 Type Library
Identity: {00021A98-0000-0000-C000-000000000046}\4.b\0\tlbimp
Path: C:\Documents and Settings\jmeile\My Documents\My Data\[Project
Path]\obj\Interop.Visio.dll
Runtime Version: [Empty]
Strong Name: False
Type: ActiveX
Version: 4.11

The name space of Visio used to be "Microsoft.Office.Interop". The versions
of the
drawing control is 1.0 and the one from the Type Library is 4.11, so, I
guess the
VisOcx is still looking for the old Visio Library. How can I solve the
problem? Is
there a new version of VisOcx that I can use with the Visio Service Pack 2?

Regards,
Josef
 
C

Chris [Visio MVP]

Yes, this is a bit annoying!

Try changing all of these:

using Visio = Microsoft.Office.Interop.Visio;

to this:

using Visio;



--
Hope this helps,

Chris Roth
Visio MVP



Josef Meile said:
Hi,

after installing the service pack 2 for Visio and the Windows XP Security
upgrades
from the 30th November, it broke my C# addon, which uses the Microsoft
Visio
11.0 Type Library to catch the events of the visio main application and it
also
contains a form which uses the Microsoft Visio 11.0 Drawing Control.

Just if it matters, I'm using Visual Studio 2003 Version 7.1.3088 and .net
Version 1.1.4322 under Windows XP Service Pack 2. I don't have .net
Version
2.0 on my
system.

Now retuning to the topic. At first The Visio Reference was broken, so, I
deleted it
and added it again through the "Add Reference" dialog. But then I got:

C:\[Project Path]\FBooleanExp.cs(9): Namespace '' already contains a
definition for 'Visio'

and the line causing this was:

using Visio = Microsoft.Office.Interop.Visio;

So, I drop it and the message went away. However, now I'm getting:

C:\...\Forms\FBooleanExp.cs(501): The type
'Microsoft.Office.Interop.Visio.Window'
is defined in an assembly that is not referenced. You must add a
reference to
assembly 'Microsoft.Office.Interop.Visio'.

The problem is here:

Visio.Window drawingWindow = (Visio.Window)this.dclVisioDrawing.Window;
---^

I added the Drawing Control by using the form designer. After doing this,
Visual
Studio adds automatically the refferences to AxVisOcx and VisOcx. This is
the
declaration of the Drawing Control:

private AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
dclVisioDrawing;

I saw the properties window of each reference and noticed that the
NameSpaces
are diferent:

* AxVisOcx
(Name): AxInterop.VisOcx
CopyLocal: True
Culture: 0
Description: Microsoft Visio 11.0 Drawing Control Type Library
Identity: {F1A8DFE4-BC61-48BA-AFDA-96DF10247AF0}\1.0\0\aximp
Path: C:\Documents and Settings\jmeile\My Documents\My Data\[Project
Path]\obj\AxInterop.VisOcx.dll
Runtime Version: [Empty]
Strong Name: False
Type: ActiveX
Version: 1.0

* VisOcx
(Name): Microsoft.Office.Interop.VisOcx
Copy Local: False
Culture: 0
Description: Microsoft Visio 11.0 Drawing Control Type Library
Identity: {F1A8DFE4-BC61-48BA-AFDA-96DF10247AF0}\1.0\0\primary
Path:
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.VisOcx\11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.VisOcx.dll
Runtime Version: [Empty]
Strong Name: True
Type: ActiveX
Version: 1.0

* Visio
(Name): Interop.Visio
Copy Local: True
Culture: 0
Description: Microsoft Visio 11.0 Type Library
Identity: {00021A98-0000-0000-C000-000000000046}\4.b\0\tlbimp
Path: C:\Documents and Settings\jmeile\My Documents\My Data\[Project
Path]\obj\Interop.Visio.dll
Runtime Version: [Empty]
Strong Name: False
Type: ActiveX
Version: 4.11

The name space of Visio used to be "Microsoft.Office.Interop". The
versions
of the
drawing control is 1.0 and the one from the Type Library is 4.11, so, I
guess the
VisOcx is still looking for the old Visio Library. How can I solve the
problem? Is
there a new version of VisOcx that I can use with the Visio Service Pack
2?

Regards,
Josef
 
J

Josef Meile

Hi Chris,

Finally I decided to uninstall Visio, reinstall it, then the Service Pack 2
and now, without doing any modification in the code it is working again. Now,
and just for the records, I will explain what I could observe before and after
reinstalling visio. I think this could be a bug; possible due
incompatibilities
between the Service Pack 2 and previous security updates.

Before reinstalling visio and after having installed the Service Pack,
I saw that the Microsoft Visio 11.0 Type Library changed its namespace
from Microsoft.Office.Interop.Visio to Interop.Visio. However, the
Microsoft Visio 11.0 Drawing Control Type Library was still under
Microsoft.Office.Interop.VisOcx. So, I guess the Drawing Control
was still looking for Microsoft.Office.Interop.Visio, which wasn't
there and that's why I got:

Visio.Window drawingWindow = (Visio.Window)this.dclVisioDrawing.Window;
---^
C:\...\Forms\FBooleanExp.cs(501): The type
'Microsoft.Office.Interop.Visio.Window'
is defined in an assembly that is not referenced. You must add a
reference to
assembly 'Microsoft.Office.Interop.Visio'.

I also tried what you said:
Try changing all of these:

using Visio = Microsoft.Office.Interop.Visio;

to this:

using Visio;

But I got a conflict with the Window and Font class of Visio. The compiler
said that
there were ambiguous declarations of such classes. So, I guess when doing
"using Visio" it somehow overrided some elements of the Windows Forms
namespace, which
I was using too. I just tried without the "using Visio" and I could access
all Visio GUI
elements as I did it before: Visio.Shape vsoShape, Visio.Page vsoPage and so
on. However,
the form where I were using the Drawing Control was still looking for Visio
under
"Microsoft.Office.Interop".

So, I uninstall Visio, install it again, and installed the Service Pack 2
and guess what? The
Visio Type Library came back to its old name space:
"Microsoft.Office.Interop.Visio", so,
"using Visio = Microsoft.Office.Interop.Visio" just worked again. I think
this namespace
change is somewhat weird and I guess the Service Pack 2 could have some
incompatibilities with
previous security updates; however, I can't assure this since microsoft
removed the previous
updates and replaced them with the Service Pack 2, so, I can't test this.
I'm just basing me
in the fact that I did a fresh install of visio and only applied the Service
Pack to it and
no other updates as I did with my old install.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top