Error in c# when i work with word file

Good day!
I wrote the code on c# and it has error in my first string: ‘Application’ is an ambiguous reference between ‘Microsoft.Graph.Application’ and ‘Microsoft.Office.Interop.Word.Application’ At line 1

My code: Microsoft.Office.Interop.Word.Application app = new Application();

I tried to make this expression shorter, like Application app = new Application(); but this also throws an error.
Also i try to write “Microsoft.Office.Interop.Word._Application app = new Application();” but this also throws an error

My imports have the lines i need.
unnamed (1)

Also i tryed: 1)restart project 2)remove the imports and add it again

Hi @Arettu63 ,

Try adding the namespace to that part as well and check.

Providing just Application (), the compiler gets confused on which namespace to be chosen.

Hence, providing the full namespace should resolve it.

Please, write how to add a namespace correctly.
Itry to write “using Microsoft.Office.Interop.Word;” in the first line and got an error:
error CS0118: ‘Microsoft.Office.Interop.Word’ is a namespace but is used like a type At line 1
error CS0210: You must provide an initializer in a fixed or using statement declaration At line 1

unnamed (2)

No need to add this.

Rewrite it like below:

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.