Search code examples
c++.netclr

Type '<Module>' from assembly ... contains more methods than the current implementation allows


I'm trying to compile a relatively big legacy c++ project in visual-studio-2013 using /clr flag. The project generates a dll.

I get the following run-time exception:

Type '<Module>' from assembly ... contains more methods than the current implementation allows

I must add that this happens in Debug configuration only (Release - works). Also, the project heavily uses templates and macros, which (I suppose) contribute to the large amount of generated methods...

There is little to no documentation regarding this problem. What I know from searching the net (don't know if it's accurate) is:

There is a limit of ~65K methods in a clr dll. All methods of all native classes go into some special <Module>, so it poses a global limit.

One suggestion was to split the project, but that's not very trivial, due to inter-class-dependencies. I suppose this is doable...

Any help would be appreciated.


Solution

  • I ended up separating code into two dlls, and removing some code that I wasn't using. The hard part was identifying "dead" code and making sure it's using templates extensively (otherwise I was just removing drops in a bucket).

    I know it's not a solution you want to hear, but I couldn't find any other working workaround.