Groups | Blog | Home
all groups > dotnet interop > february 2004 >

dotnet interop : Namespace " already contains a definition for 'Word' ????


BBFrost
2/11/2004 4:17:07 PM
This is NOT my month. Everywhere I turn our C# apps are tossing hair balls!

In this case I was cleaning up my development machine and dumped an old
version of the Net Framework and reinstalled the latest version of Net
Framework 1.1 because of another problem.

Now the word interop program I'm developing throws

Namespace " already contains a definition for 'Word'

when I try to compile.


I haven't had any luck at all tracking this error down on the web, so I'm
stuck.


I'm runing

Os: Win2000
Office 2002
I'm Referencing the Microsoft Word 10.0 Object Library version 8.2

The program complied fine before I deleted the old version of the Net
Framework 1.37.... (English).


using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using wrdCommonClassLibrary;
using Word = Microsoft.Office.Interop.Word;

namespace wrdCommonClassLibrary
{


References:

Microsoft.Office.Core
stdole
System
System.Data
System.Drawing
System.Windows.Forms
System.XML
VBIDE
Word


Microsoft.Office.Core
stdole
VBIDE
Word

appear when I set the reference to the Microsoft Word 10.0 Object Library
version 8.2


The error highlights "using Word = Microsoft.Office.Interop.Word;" in each
of the classes
that use word interop.


Any help would be greatly appreciated here.

Thanks in advance.

Barry
Oregon


v-yiy NO[at]SPAM online.microsoft.com (
2/12/2004 8:28:14 AM
Hi Barry,

You referenced the type library in VS.NET 2003, right?
In Vs.NET 2003 the name space in the interop assembly is Word not
Microsoft.Office.Interop.Word.
so removing this "using line" should clear this error.

Besides, You may download and try the PIA for OfficeXP

http://download.microsoft.com/download/c/4/8/c4813cc0-a4d4-4bb4-b486-9cbd56f
38235/oxppia.exe

To make Microsoft? Office? XP applications available to Microsoft Visual
Studio? .NET developers, Microsoft has created several primary interop
assemblies (PIAs) that contain the official description of commonly used
Microsoft Office XP type libaries for applications such as Microsoft Access
2002, Microsoft Excel 2002, Microsoft FrontPage? 2002, and more.

Microsoft has customized the Office XP PIAs to make it easier for managed
code to interoperate with the Office XP COM type libraries. Avoid using any
Office XP COM interop assembly that is not provided as part of the Office
XP PIAs, or any Office XP COM interop assembly that is generated by
Microsoft Visual Studio .NET at design time because they are considered
unofficial.

Hope it helps!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
BBFrost
2/12/2004 11:52:37 AM
Ying-Shen Yu,

Thanks for your quick reply. The help is greatly appreciated since Net 2003
glitches have really hammered my productivity over the last 2 weeks.

Removing the "using Word = Microsoft.Office.Interop.Word;" did indeed work.
Howerver, I was really surpised to find a bunch of errors when I tried to
recompile.

oWordTable.Rows[01].HeadingFormat has changed to
oWordTable.Rows.Item(01).HeadingFormat
oWordTable.Columns[01].SetWidth has changed to
oWordTable.Columns.Item(01).SetWidth

oWordDoc.Bookmarks.get_Item(ref oMsWordBookmark).Range
has changed to
oWordDoc.Bookmarks.Item(ref oMsWordBookmark).Range.

Is there someplace that all of these changes / updates have been documented
??

I'm still using Office 2002 & I'm Referencing the Microsoft Word 10.0 Object
Library version 8.2 so the changes must either originate from VS Net 2003
or the Net Framework 1.1.

B.T.W. I thought "Microsoft Word 10.0 Object Library version 8.2" >> were
<< the Office XP PIA's.

Barry
Oregon


[quoted text, click to view]

v-phuang NO[at]SPAM online.microsoft.com
2/13/2004 2:19:14 AM
Hi Oregon,

Based on my experience, the problem is somewhat strange.
To isolate the problem, I hope you may need check if you has referenced the
assembly in the GAC not the interop assembly that IDE produce for you.

In the references in the solution explorer, right click on the Word and
click Properties.
In the Properties page, the Path is where the assembly you are using now.
If you are using the PIA, the path should point to the
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word, while not the
current Project's bin directory.

[quoted text, click to view]

the "Microsoft Word 10.0 Object Library version 8.2" is the olb file, if
you have installed the PIA, .NET will point to the GAC automatically,
otherwise it will produce one for you which is not the PIA.

To register the PIA, you may try to download the office XP PIA, Yin-Shen
refer to in his last post and run the exe file, it will exact all the file
into a directory. Navigate to the directory and run the register.bat which
will do the stuff for you.

After you done that, try to check if the Word in the references 's path has
been pointed to the GAC.

You may have a try and let me know the result.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Shimok
2/14/2004 4:18:30 PM
Peter,

Thanks for the quick response. My project is not currently referring to the
GAC. It points to the local 'project' version of the
Microsoft.Office.Interop.Word .dll.

However, after I made the changes to the application mentioned in my last
post, my application seems to running working again. We've been having a
very difficult time moving from Net 2002 to Net 2003 and this issue seemed
to be just another artifact of the migration.

By the way, why should it matter whether the GAC or the local version of the
Microsoft.Office.Interop.Word .dll is used ?? I thought that not having to
use a central repository like the GAC was one of the strengths of the .Net
paradigm ??

As a result I have not focused on use of the GAC up to this point, so I'll
need to research how make sure Microsoft.Office.Interop.Word is added to the
GAC and how to redirect the project to point to the GAC.

Again thanks for the advice, it is very much appreciated.

Barry
in Oregon


[quoted text, click to view]

v-yiy NO[at]SPAM online.microsoft.com (
2/17/2004 3:46:47 AM
Hi Barry,

Basically, the PIA will be added to GAC after the register.bat is executed.
You may check if it is successfully added to GAC using the Assembly Cache
Viewer, it is a windows shell extension that allows you view and manipulate
the contents of the GAC in Windows Explorer.

<Assembly Cache Viewer (Shfusion.dll)>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpgrfassemblycacheviewershfusiondll.asp

If the registration is successful, you should see there are several
assemblies
like Microsoft.Office.Interop.Word ,Microsoft.Office.Interop.Excel , etc.
You may follow the steps below to check if your project is using the
correct PIA.
1. Right click on the referenced assembly item in the solution explorer
2. Select "Property" in the context menu. If the path is like
c:\windows\assmebly, then your project is using the PIA.

Please let me know if you have any further questions on this issue.

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
BBFrost
2/17/2004 7:19:32 AM
Thanks,

Really appreaciate the information.

Best wishes,

Barry
in Oregon

[quoted text, click to view]

B G
2/23/2004 2:47:09 PM
I am having an issue which is sort of similar to this thread. I have
created a .NET Addin on a machine that is running Office 2003. I
downloaded the latest PIAs and am referencing them in my application. I
would now like to run the application on a machine that has Office 2002
installed on it. I am running into issues with getting the application
to run correctly. Is this due to not have the 11.0 object libraries
loaded on that machine? What is my work around? If the work around is
to reference the 10.0 libraries, how would I do that on a machine that
already has the 11.0 libraries installed on it and where might I get
them? I can't seem to locate the 10.0 libraries.

Any help would be greatly appreciated as I am having major issues trying
to figure out how to get this resolved.

Thanks.



*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button