【发布时间】:2014-06-12 16:01:48
【问题描述】:
我正在尝试为 Visual Studio 2012 创建一个新项目向导。这将是一个创建多个 C++ 文件并将它们添加到项目中的向导。我已经为 VS 2005 创建了一个类似的向导。我正在尝试使用 IDTWizard 界面创建它。我按照这个演练:http://msdn.microsoft.com/en-us/library/7k3w6w59(v=vs.110).aspx
当我尝试使用该向导时,我收到一条错误消息,显示“在文档的顶层无效”。当我查看 oleview.exe 显示的数据时,我的 dll 显示为已注册的 COM 对象。我究竟做错了什么?我是否应该像使用 html/javascript 创建 VS2005 向导一样执行此操作?我的代码如下:
Wizard.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using EnvDTE80;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SystemsModuleWizard
{
[ComVisible(true)]
[Guid("FE7DC545-30DC-445B-8130-897C5F3114EC"), ProgId("SystemsModuleWizard.WizardClass")]
public class WizardClass : IDTWizard
{
public void Execute(object Application,
int hwndOwner, ref object[] contextParams,
ref object[] customParams,
ref EnvDTE.wizardResult retval)
{
MessageBox.Show("The wizard is running");
}
}
}
AssemblyInfo.cs:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SystemsModuleWizard")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SystemsModuleWizard")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ab29b7df-32c4-4dca-ade4-a31f687b9331")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
【问题讨论】:
-
这是由 XML 解析器生成的错误消息。远离您的代码 sn-ps。
标签: c# visual-studio-2012 wizard