Mixed CLI Assembly Link/Project Reference RRS feed

  • Question

  • We have been converting a number of legacy COM components to mixed CLI Assemblies over the last few weeks and have hit a minor link issue that I was hoping somebody might know of a better solution. Generally speaking, the vast majority of our CLI Assemblies are MFC Extension DLL's that contain a combination of ref classes as well as native exported classes.

    Before we starting this work, we had just changed our entire build system to use project references. In doing so, we realized that defining project references automatically performed the necessary linkage without having to explicitly define all of the *.lib files in the VC++ Linkage property page. Once we started converting our projects to CLI Assemblies, everything seemed to build/link OK in DEBUG; however, our build began to fail once it began building RELEASE?!

    What I have discovered is that, for some strange reason, a CLI Assembly will link 100% correctly using only project references in DEBUG mode; however, RELEASE requires you to explicitly identify all .lib files for all dependent CLI Assemblies . In essence, we had to reintroduce all of those explicit library names back into our projects.

    I'm not sure I understand why it fails only in RELEASE builds but my suspicion is that the compiler is making assumptions on whether to link based on whether the /CLR compiler flag is enabled or whether there are any ref classes and/or defined types for that particular Assembly.

    At the end of the day, is there any possible way to use only project references to handle the linkage without specifying the import .lib files for this type of scenario?

    Saturday, December 31, 2011 6:51 PM

All replies

  • Hi Scott,

    Thank you for your question.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
    Thank you for your understanding and support.

    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 3, 2012 3:54 AM
  • Thanks Min for letting me know. I'll periodically check back or you may email me directly if you need more information.



    Tuesday, January 3, 2012 10:28 PM
  • RELEASE mode use different link settings against DEBUG mode, to find out the difference, please open the property page of your C++/CLI project in Visual Studio, choose Configuration Properties à Linker à Command Line, and you can see all options used at link phase, please switch from DEBUG to RELEASE, and compare those options.

    Next step is to change the different options back one-by-one, you will find out which option makes linking failed in RELEASE mode, and we can do more investigate why the option make the difference.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Eric Yang
    Microsoft Online Community Support
    Friday, January 27, 2012 8:02 AM