DEBUG出错,请大家指点,我刚刚开始学,什么都不懂,请大家帮帮我在WORD里添加插件,
修改Connect.cs的一些函数namespace AK47
{
using System;
using Extensibility;
using System.Runtime.InteropServices;
         using System.Windows.Forms;
    
public class Connect : Object, Extensibility.IDTExtensibility2
{
LINE28:   CommandBarButton InsertPictureButton;
....后面省略
debug结果:
E:\My project\lj\AK47\AK47\Connect.cs(28,9): 错误 CS0246: 找不到类型或命名空间名称“CommandBarButton”(是否缺少 using 指令或程序集引用?)
E:\My project\lj\AK47\AK47\Connect.cs(168,40): 错误 CS0246: 找不到类型或命名空间名称“CommandBarButton”(是否缺少 using 指令或程序集引用?)编译完成 -- 2 个错误,0 个警告
========== 生成: 0 成功或最新,1 失败,0 被跳过 ==========是我的commandBarButton用的有问题么?请大家帮忙看看,感激中~~~~

解决方案 »

  1.   

    添加Microsoft Office 11.0 Object Library引用,这个是COM,我的Office 2003是11的版本,当然楼主的不一定是这个版本号。using Microsoft.Office.Core;
      

  2.   

    回楼上,
    原来就添加了word的dll了,加上using Microsoft.Office.Core;
    后,debug,原来的问题解决了,但是有了新问题,麻烦你帮我看看,谢谢:
    e:\My project\lj\AK47\AK47\Connect.cs(121,91): 错误 CS0103: 当前上下文中不存在名称“BindingFlags”
    e:\My project\lj\AK47\AK47\Connect.cs(126,84): 错误 CS0103: 当前上下文中不存在名称“BindingFlags”
    e:\My project\lj\AK47\AK47\Connect.cs(127,99): 错误 CS0103: 当前上下文中不存在名称“BindingFlags”
    e:\My project\lj\AK47\AK47\Connect.cs(149,13): 错误 CS0103: 当前上下文中不存在名称“InsertPicutreButton”
    e:\My project\lj\AK47\AK47\Connect.cs(151,43): 错误 CS0103: 当前上下文中不存在名称“ture”
    e:\My project\lj\AK47\AK47\Connect.cs(152,40): 错误 CS0103: 当前上下文中不存在名称“new_CommandBarButtonEvents_ClickEventHandler”
    e:\My project\lj\AK47\AK47\Connect.cs(178,41): 错误 CS1002: 应输入 ;
    e:\My project\lj\AK47\AK47\Connect.cs(178,41): 错误 CS1525: 无效的表达式项“.”
    e:\My project\lj\AK47\AK47\Connect.cs(178,42): 错误 CS1002: 应输入 ;原程序:
    ……
        CommandBars oCommandBars;
                CommandBar oStandardBar;            try
                {
      LINE121      oCommandBars = (CommandBars)wordApp.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, wordApp, null);
                }
                catch (Exception)
                {
                    object oActiveExplorer;
                    oActiveExplorer = wordApp.GetType().InvokeMember("ActiveExplorer", 
    LINE126     BindingFlags.GetProperty, null, wordApp, null);
                    oCommandBars = (CommandBars)oActiveExplorer.GetType().InvokeMember
    LINE 127   ("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null);
                }……
    LINE149     InsertPicutreButton.FaceId = 6578;
                InsertPictureButton.Tag = "插入图片";
    LINE151     InsertPictureButton.Visible = ture;
    LINE152     InsertPictureButton.Click+=new_CommandBarButtonEvents_ClickEventHandler(InsertPictureButton_Click);
            }
    ……
            if (ofd.ShowDialog()==DialogResult.OK)
                    {
                        object omissing=System.Reflection.Missing.Value;
    LINE178             wordApp ActiveWindow.Selection.Inlineshapes.AddPictures(
                            ofd .FileName,ref omissing ,ref omissing,ref omissing);
                    }我刚开始学,什么都不懂,麻烦大家了~~~~感激不尽!!!!!
      

  3.   

    这代码哪来的啊,都是些小错误
    BindingFlags找不到,true写成了ture,还掉了分号
      

  4.   

    我没学过C#,是照着别人给的menu做的,好茫然.麻烦楼上了,帮我看看好么?其他的错误我明白了.那个BindingFlags是怎么一回事啊?
      

  5.   

    using System.Reflection;   //加在前面有using的地方
      

  6.   

    太谢谢楼上了,能不能再帮我看看这几个问题,太感谢了!!!!LINE149           InsertPicutreButton.FaceId = 6578
    LINE152
        InsertPictureButton.Click+=new_CommandBarButtonEvents_ClickEventHandler(InsertPictureButton_Click);
    LINE178
      object omissing=System.Reflection.Missing.Value;
                        wordApp ActiveWindow.Selection.Inlineshapes.AddPictures(
                            ofd .FileName,ref omissing ,ref omissing,ref omissing);e:\My project\lj\AK47\AK47\Connect.cs(149,13): 错误 CS0103: 当前上下文中不存在名称“InsertPicutreButton”
    e:\My project\lj\AK47\AK47\Connect.cs(152,40): 错误 CS0103: 当前上下文中不存在名称“new_CommandBarButtonEvents_ClickEventHandler”
    e:\My project\lj\AK47\AK47\Connect.cs(178,41): 错误 CS1002: 应输入 ;
    e:\My project\lj\AK47\AK47\Connect.cs(178,41): 错误 CS1525: 无效的表达式项“.”
    e:\My project\lj\AK47\AK47\Connect.cs(178,42): 错误 CS1002: 应输入 ;