none
Warning C4691 when building a C++/CLI library referencing a PCL RRS feed

  • Question

  • I've built a PCL out of some classes that I built into a Windows 8 Store app, and am trying to use it in a C++/CLI library so I can interface with some old C++ code that provides some other functions.
    Unfortunately, I'm getting warnings like these when I build:
    warning C4691: 'System::Object' : type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
    warning C4691: 'System::Threading::Tasks::Task' : type referenced was expected in unreferenced assembly 'System.Threading.Tasks', type defined in current translation unit used instead
    Smelling a rat, I decided to build a Class Library (not portable) to reference in my C++/CLI implementation, and the warnings are gone.
    Are the warnings in the PCL version ignorable?

    I built with exactly the same source files by the way.  No changes between versions.  I just dropped links onto the new project file.


    Anthony Wieser | Wieser Software Ltd | www.wieser-software.com


    Tuesday, March 10, 2015 8:02 AM

All replies

  • Hi Anthony,

    As we know C++/CX in Windows Store App use different Type system as C++/CLI, see this for more information: Type System,  for example the Platform::Object Class is instead of System::Object.

    However if we want to use existing class library in Windows Store App, we can enable /ZW (Windows Runtime Compilation) setting in our existing project, see my screenshot:

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 11, 2015 2:45 AM
  • Hi Anthony,

    Are you writing a Windows Store app? Or are you trying to take code from your Windows Store app to a desktop app using C++/CLI?

    Windows Store apps do not use C++/CLI and cannot use managed libraries from C++. While the C++/Cx extensions look similar to C++/CLI they run as native code not managed code.

    Your PCL is a managed library and can be called from a C# or a VB app. Depending on the details of what you're doing you may be able to write a Windows Runtime Component in C# which consumes your PCL. You can then call the Windows Runtime Component from your C++ app.

    Wednesday, March 11, 2015 3:14 AM
  • I wrote a Windows Store app, and found I needed some of the classes in the library.

    So, I built a PCL, in the hope of sharing it with a WPF app.

    It turns out some of the features of the WPF app required interfacing to a C++/CLI dll to get to some old C++ code.

    When I referenced the PCL from the C++/CLI project, I got the errors listed above.


    Anthony Wieser | Wieser Software Ltd | www.wieser-software.com

    Wednesday, March 11, 2015 6:53 AM
  • Hi Anthony for help with using the PCL from C++/CLI you'll need to ask in the appropriate desktop app forum.

    I'll move this to a closer forum. My apologies if it's still not quite right as there are several which could be applicable and I'm not familiar enough with those areas to know which is best.

    Friday, March 13, 2015 1:31 AM
  • https://msdn.microsoft.com/en-us/library/dy1c794f.aspx?f=255&MSPPError=-2147217396

    Does this warning persist If you add this code?

    #using "mscorlib.dll"

    And I think these warning is ignorable, because you have no another assembly define 'System::Object' type, right? 

    Friday, March 13, 2015 2:29 AM
  • Yes, it seems to.  I added the #using to the end of Stdafx.cpp after the include, so it should have taken effect.

    I should also add that along with the warning I get a diagnostic that says:
       This diagnostic occurred while importing type 'MyFramework::MyType' from assembly 'MyPCL, Version 1.0.0.0, Culture=neutral, PublicKeyToken=null'.


    Anthony Wieser | Wieser Software Ltd | www.wieser-software.com

    Friday, March 13, 2015 7:52 AM