visual-studio - 如何将 "ATL Simple Object"添加到升级到 VS 2010 的旧 ATL DLL 项目?

标签 visual-studio visual-studio-2010 atl

我们有一个已经存在很长时间(可能早在 Visual Studio 6)的 DLL 项目,它已针对 VS 的每个新版本进行了更新。该项目包含许多使用 ATL 实现的 COM 类。

升级到 VS 2010 后,该项目仍然可以正常构建。但是,如果我尝试右键单击该项目并选择 添加 -> 类... -> ATL 简单对象 ,我收到一个错误框,上面写着:

ATL classes can only be added to MFC EXE and MFC Regular DLL projects or projects with full ATL support.



这在 VS 2008 中有效。

当我查看项目属性时,使用 MFC 设置为 使用标准 Windows 库 和 ATL 的使用设置为 不使用 ATL .我将这些更改为 在共享 DLL 中使用 MFC 到 ATL 的动态链接 分别,但仍然得到相同的错误。

我知道如何在不使用向导的情况下添加新的 ATL 对象,并且我可以尝试使用 VS 2010 从头开始​​重新创建项目以使其满意。但是有没有人知道让 VS 允许我将 ATL 简单对象向导与它不识别为“具有完全 ATL 支持”的项目的项目一起使用的简单方法?

最佳答案

查询 this thread out .

似乎添加此片段信息您的 ATL C++ 代码使其工作。您不需要实际构建项目,只需在完成向导后删除这些内容(前提是该解决方案适合您)。

// Added fake code begins here

class CAppModule : 
    public CComModule
{
};

// Added fake code ends here, below is regular ATL project stuff

CAppModule _Module;

这就是这一切的来源,在 $(VisualStudio)\VC\VCWizards\1033\common.js :
/******************************************************************************
Description: Returns a boolean indicating whether project is ATL-based.
oProj: Project object
******************************************************************************/
function IsATLProject(oProj)
{
    try
    {
        var oCM = oProj.CodeModel;
        oCM.Synchronize();
        // look for global variable derived from CAtlModuleT
        var oVariables = oCM.Variables;
        for (var nCntr = 1; nCntr <= oVariables.Count; nCntr++)
        {
            var oVariable = oVariables(nCntr);
            var strTypeString = oVariable.TypeString;
            if (strTypeString == "ATL::CComModule" || strTypeString == "ATL::CAutoThreadModule")
            {
                return true;
            }

关于visual-studio - 如何将 "ATL Simple Object"添加到升级到 VS 2010 的旧 ATL DLL 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8594856/

相关文章:

visual-studio - Visual Studio 中的 "Add Existing Item..."是如何工作的?

mysql - 尝试使用 MySQL ADO.NET 驱动程序连接到数据库时,Visual Studio 2010 从数据库生成模型时出现错误消息,如何解决?

visual-studio - 无法打开项目 <名称>,因为无法创建 Microsoft Visual C# 2010 编译器。请重新安装 Visual Studio

wpf - 关于在 C# (WPF) 中对 COM 对象进行异步调用的问题

visual-studio - MSTest 和 AppDomains

visual-studio - 使用 Visual Studio 2017 调试 NuGet 包

visual-studio - 如何让 Visual Studio 2015 安装程序知道我已经拥有 Android SDK?

c# - 如果 Visual Studio 的 Intellisense 不建议一个选项——这是否意味着它并不总是受支持?

c++ - 关闭应用程序时如何抑制 "There are still active COM objects in this application"错误?

c - 在 Visual Studio 中识别项目