在使用/ CLR编译的MFC项目中是否有任何类计数限制 [英] Is there any class count limit in MFC project compiled with /CLR

查看:478
本文介绍了在使用/ CLR编译的MFC项目中是否有任何类计数限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有风险落入太具体的问题...



给定一个使用/ CLR编译的C ++ MFC(混合,不动摇)项目,我有



当我向此项目添加一个新类时,编译时会出现错误,在调试模式下执行。


未知模块中发生了
类型的未处理异常System.IO.FileLoadException p>

其他信息:无法加载文件或程序集ProjectA,
Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null' b依赖。找不到或加载类型。 (来自HRESULT的异常:
0x80131522)


ProjectA MFC项目本身的名称。在项目配置中没有对任何 ProjectA 程序集的引用,并且没有对另一个自定义程序集的引用。



这个项目只有一些.NET框架程序集的引用,以允许项目中的一些自定义定义的类可以使用CLR类。



然后,问题是...




  • 你知道在MFC C ++项目上是否存在类号的限制?



编辑:



正如我在注释中所说,在发布模式下,编译成功无误。



此外,我清理,构建,清理,关闭Visual Studio,重新启动计算机...,问题仍然出现。
如果我在200个类中,没有错误。当我去201,错误出现。



目前我想在一个新的默认MFC项目,添加类,直到到达到200,以确认有是一个真正的限制。



编辑2:错误已修复



@MSX @frymode 告诉我如何避免他的评论错误。



在Visual Studio开发环境中( source / source ):


  1. 打开项目的属性页对话框。

  2. 点击C / C ++文件夹。

  3. 点击代码生成属性页。

  4. String pooling(/ GF)property。

谢谢你们!

解决方案

这个链接表明,在命名空间(不是项目)中可以拥有的类型数量没有限制。考虑到命名空间可以在不同的程序集之间拆分,你至少在理论上可以有无限数量的类型。但是,此信息确认一个.DLL
中的类的最大数量是16777215.可能在你达到这个数量的类之前,你将耗尽内存)



仅供参考:似乎有一个

PS:
以下是从
此链接获取的问题的解决方案


  1. 打开项目的属性页对话框。

  2. 点击C / C ++文件夹。

  3. 点击代码生成属性页。

  4. String Pooling属性。


With the risk to fall into too specific question...

Given a C++ MFC (mixed, not shaked) project compiled with /CLR, I have 200 classes already defined.

When I add a new empty class to this project, an error raises when I compile and execute in debug mode.

An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'ProjectA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Could not find or load a type. (Exception from HRESULT: 0x80131522)

ProjectA is the name of the MFC project itself. There is no reference to any ProjectA assembly on project configuration, and there is no reference to another custom assembly.

This project only have references to some .NET Framework assemblies, in order to allow that some of custom defined classes in the project can use CLR classes.

Then, the question is...

  • Do you know whether there is any limitation of class number on a MFC C++ project?

EDIT:

As I say in comments, in release mode the compilation succeed without errors.

Also, I clean, build, clean, close Visual Studio, reboot computer... and the problem still appears. If I keep in 200 classes, there is no error. When I go to 201, the error appears.

Currently I'm trying to reproduce in a new default MFC project, adding classes till arrive to 200, to confirm that there is a real limitation.

EDIT 2: ERROR FIXED

Great. @MSX and @frymode show me how avoid the error with his comments.

In the Visual Studio development environment (source / source):

  1. Open the project's Property Pages dialog box.
  2. Click the C/C++ folder.
  3. Click the Code Generation property page.
  4. Modify the Enable String Pooling (/GF) property.

Thank you guys!

解决方案

This link shows that there's no limit to the number of types you can have in a namespace (not a project). Considering, that a namespace can be split across different assemblies, you could, at least in theory, have an unlimited number of types. However, this post affirms that the maximum number of classes in a .DLL is 16777215. Probably, you'll run out of memory before you reach that number of classes :)

Just for information: there seems to be a limit to the number of fields per class, though.

P.S.: Here's the solution to your problem taken from this link

  1. Open the project's Property Pages dialog box.
  2. Click the C/C++ folder.
  3. Click the Code Generation property page.
  4. Modify the Enable String Pooling property.

这篇关于在使用/ CLR编译的MFC项目中是否有任何类计数限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆