命名空间“Microsoft”中不存在类型或命名空间名称“Office”(您是否缺少程序集引用?) [英] The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
问题描述
嗨朋友
我遇到了问题。如果你们中的任何人帮我解决我的问题,我会很感激你们。
实际上我想通过我的C#.Net程序调用Excel应用程序。为此我用Excel添加了
= Microsoft.Office.Interop.Excel;
我为此做了如下 - >
我的应用程序 - > RC-> Add Referenece-> COM-> Microsoft Excel 12.0 Object Library。
我没找到Microsoft.Office.Interop.Excel;
现在在Complie时间我是得到错误 - >
命名空间Microsoft中不存在类型或命名空间名称Office(您是否缺少程序集引用?)< br $> b $ b
我错过了什么或做错了什么?
有人可以帮我解决这个问题吗?
提前感谢。
Swapnil Borkar
(软件培训生)
Hi Friends
I am stuck up with a problem.I would be grateful to you people if anyone of you help mein solving my problem.
Actually I want to invoke an Excel application through my C# .Net program.For that I added the
using Excel= Microsoft.Office.Interop.Excel;
For that I did as below-->
My application->RC->Add Referenece->COM->Microsoft Excel 12.0 Object Library.
I did not find Microsoft.Office.Interop.Excel;
Now at Complie time I am getting a error as-->
The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Am I missing anything or doing something wrong?
Can anybody help me for solving this problem??
Thanking in Advance.
Swapnil Borkar
(Software Trainee)
推荐答案
AddReference->.NET->
Microsoft.Office.Interop.Excel.
您还需要添加对Microsoft Office 12.0对象库的引用,以获得对基本支持的支持。办公室互操作。请参阅本文 [ ^ ]了解更多信息。
You need also to add a reference to the Microsoft Office 12.0 Object Libray, for the base support for office interop. See this article[^] for more information.
如果您使用的话,我认为您不想添加对COM库的引用C#。您需要主互操作程序集,但您必须检查MSDN文档以查找它们的位置。我认为他们的存在也取决于你正在使用的Visual Studio版本(我不认为Express版本包含它们)。
一个好的开始的地方可能是在Visual Studio中创建一个Office插件项目并查看引用最终的内容。
Altenrativly,看看对象浏览器看看Excel对象库放置了什么命名空间。但是,请注意,这不是推荐的做事方式。
I don't think you want to add a reference to the COM library if you're using C#. You want the Primary Interop Assemblies, but you'll have to check the MSDN documentation for where to find them. I think their presence also depends on the version of Visual Studio you're using (I don't think the Express editions include them, for example).
A good place to start might be creating an Office plug-in project in Visual Studio and seeing what the references end up being.
Altenrativly, have a look in Object Browser to see what namespace the Excel Object Library has been put in. Be warned, however, that this is not the recommended way of doing things.
这篇关于命名空间“Microsoft”中不存在类型或命名空间名称“Office”(您是否缺少程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!