简体   繁体   English

Natvis用于可能被编译为dll或lib的类型

[英]Natvis for a type that may be compiled into dll or lib

I have a solution in visual studio that has one configuration that allows for each project to be statically linked into the main exe, and another configuration that compiles each project as its own dll. 我在Visual Studio中有一个解决方案,该解决方案的一种配置允许将每个项目静态链接到主exe,另一种配置将每个项目编译为自己的dll。

The idea being that I can develop using DLLs, minimising downtime during compilation and linking, but when I release to the public, there's just one exe. 我的想法是可以使用DLL进行开发,从而最大程度地减少了编译和链接期间的停机时间,但是当我发布给公众时,只有一个exe。

Unfortunately this means that a type created in one of these projects appears to need 2 natvis files so that they can be debugged in either configuration. 不幸的是,这意味着在这些项目之一中创建的类型似乎需要2个natvis文件,以便可以在任一配置中对其进行调试。

These 2 natvis files are otherwise identical except for the myProject.dll! 除myProject.dll之外,这两个natvis文件完全相同! prefix applied to all namespaces in the natvis for the dll configuration. 前缀应用于natvis中dll配置的所有名称空间。 (When running a statically linked exe, the natvis containing the reference to the type in a dll fails, causing the whole file to be ignored, not just that type) (运行静态链接的exe时,包含对dll中类型引用的natvis失败,导致整个文件被忽略,而不仅仅是该类型)

Is the best solution to this situation just to maintain 2 natvis files per type? 对这种情况的最佳解决方案是仅为每种类型维护2个natvis文件吗? Is it possible to generate the natvis from a template? 是否可以从模板生成natvis? Is it possible to make the reference to the dll optional? 是否可以使对dll的引用为可选?

(I'm using Visual Studio 2015, but please let me know if 2017+ has a solution for this) (我正在使用Visual Studio 2015,但请让我知道2017+是否为此提供了解决方案)

Thanks 谢谢

I'm using Microsoft Visual Studio Community 2017 Version 15.6.2 and it works for me with a single .natvis type decl. 我正在使用Microsoft Visual Studio Community 2017版本15.6.2,它对我有用,并且具有单个.natvis类型decl。 I've got my .natvis and header files in a shared project which is referenced by both my shared project's implementation .dll project and my application's .exe project. 我的共享项目中有.natvis和头文件,共享项目的实现.dll项目和应用程序的.exe项目都引用了该文件。 I just specify the simple type name without the Shared.dll! 我只指定了简单的类型名称,没有Shared.dll! prefix and it works. 前缀,它的工作原理。 I hope this helps. 我希望这有帮助。 =) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM