从命令行编译 MS Office 互操作应用程序
我如何使用 csc.exe 从命令行成功编译此代码,就我应该引用哪个 dll 而言。 我希望它能够与 Office 2007 和 Office 2003 一起使用。
我使用 .Net Framework SDK 2.0。
我收到此编译错误:
(2,37):错误 CS0234:命名空间“Microsoft.Office”中不存在类型或命名空间名称“Interop”(您是否缺少程序集引用?)
源代码:
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
namespace PPInterop
{
class Program
{
static void Main(string[] args)
{
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentations pres = app.Presentations;
PowerPoint._Presentation file = pres.Open(@"C:\project\JavaTut1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
file.SaveCopyAs(@"C:\project\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
}
}
}
how do I successfully compile this code from the commandline, using csc.exe, in terms of which dll's I should reference. I would like this to work with Office 2007 as well as Office 2003.
I am use .Net Framework SDK 2.0.
I get this compilation error:
(2,37): error CS0234: The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)
Source code:
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
namespace PPInterop
{
class Program
{
static void Main(string[] args)
{
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentations pres = app.Presentations;
PowerPoint._Presentation file = pres.Open(@"C:\project\JavaTut1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
file.SaveCopyAs(@"C:\project\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要找到实现您引用的接口的 dll 的路径,然后查看 csc.exe 的命令行参数以了解如何将这些引用添加到您的命令中。
You need to find the paths to the dlls implementing the interfaces you reference, then look at the command-line parameters for csc.exe to learn how to add those references into your command.
您需要包含 Microsoft.Office.Interop.PowerPoint 路径应类似于:
C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.PowerPoint.dll for 07 并用 Office11 替换 Office12 for 03 我相信
You need to include Microsoft.Office.Interop.PowerPoint the path should be something like:
C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.PowerPoint.dll for 07 and replace Office12 with Office11 for 03 I believe