| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 862 人关注过本帖
标题:关于MessageBox
只看楼主 加入收藏
4me
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-7-14
收藏
 问题点数:0 回复次数:2 
关于MessageBox

DEBUG出错,请大家指点,我刚刚开始学,什么都不懂,请大家帮帮我

在WORD里添加插件,reference里加了
System.Windows.Forms,
System.Drawing,
System.XML,
Microsoft Word 11.0 Object Library
然后修改Connect.cs

namespace AK47
{
using System;
using Extensibility;
using System.Runtime.InteropServices;


#region Read me for Add-in installation and setup information.
// When run, the Add-in wizard prepared the registry for the Add-in.
// At a later time, if the Add-in becomes unavailable for reasons such as:
// 1) You moved this project to a computer other than which is was originally created on.
// 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
// 3) Registry corruption.
// you will need to re-register the Add-in by building the AK47Setup project,
// right click the project in the Solution Explorer, then choose install.
#endregion

/// <summary>
/// The object for implementing an Add-in.
/// </summary>
/// <seealso class='IDTExtensibility2' />
[GuidAttribute("D3B99C53-E487-4C2C-AD4F-77D3DC43A3C8"), ProgId("AK47.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
private Word.Application wordApp;
/// <summary>
/// Implements the constructor for the Add-in object.
/// Place your initialization code within this method.
/// </summary>
public Connect()
{
}

/// <summary>
/// Implements the OnConnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being loaded.
/// </summary>
/// <param term='application'>
/// Root object of the host application.
/// </param>
/// <param term='connectMode'>
/// Describes how the Add-in is being loaded.
/// </param>
/// <param term='addInInst'>
/// Object representing this Add-in.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{

//applicationObject = application;
//addInInstance = addInInst;
if (application is Word.Application)
{
wordApp=(Word.Application)application;
}

}

/// <summary>
/// Implements the OnDisconnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being unloaded.
/// </summary>
/// <param term='disconnectMode'>
/// Describes how the Add-in is being unloaded.
/// </param>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
wordApp = null;
}

/// <summary>
/// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface.
/// Receives notification that the collection of Add-ins has changed.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnAddInsUpdate(ref System.Array custom)
{
}

/// <summary>
/// Implements the OnStartupComplete method of the IDTExtensibility2 interface.
/// Receives notification that the host application has completed loading.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnStartupComplete(ref System.Array custom)
{
MessageBox.Show(wordApp.ActiveDocument.Name);
}

/// <summary>
/// Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
/// Receives notification that the host application is being unloaded.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnBeginShutdown(ref System.Array custom)
{
}

private object applicationObject;
private object addInInstance;
}
}
debug的结果是------ 已启动生成: 项目: AK47, 配置: Debug Any CPU ------
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\Extensibility.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll /reference:obj\Debug\Interop.Microsoft.Office.Core.dll /reference:obj\Debug\Interop.VBIDE.dll /reference:obj\Debug\Interop.Word.dll /debug+ /optimize- /out:obj\Debug\AK47.dll /target:library AssemblyInfo.cs Connect.cs
e:\My project\lj\AK47\AK47\Connect.cs(106,13): 错误 CS0103: 当前上下文中不存在名称“MessageBox”

编译完成 -- 1 个错误,0 个警告
========== 生成: 0 成功或最新,1 失败,0 被跳过 ==========


搜索更多相关主题的帖子: MessageBox 
2006-07-14 11:52
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 
引用了Word组件后,会出现这样的问题,你在使用方法时最好把全部命名空间写全。如:

System.Windows.Forms.MessageBox

public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2006-07-14 17:14
4me
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-7-14
收藏
得分:0 

谢谢楼上
但是这样一调试就停不下来了,
不过好在点"停止调试",看生成是没有问题了
不知道还有什么问题,请教楼上,谢谢

2006-07-14 17:43
快速回复:关于MessageBox
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025135 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved