locked
Windows::Storage::ApplicationData::Current Not Found in C++

    Question

  • My C++ code, which is part of Media Foundation Transform tend to able to run in Windows Store App (Metro)

    I modify the C++ GrayscaleTransform to include the following code.

    However, my C++ code fails to locate namespace Windows::Storage.

    LPCWSTR zPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data();

    Is there any additional settings I need to do?

    I can make it compiled, by turning on Consume Windows Runtime Extension.

    enter image description here

    But by doing this, it will give me additional linking error and warnings.

    warning LNK4197: export 'DllGetActivationFactory' specified multiple times; using first specification 
    warning LNK4197: export 'DllCanUnloadNow' specified multiple times; using first specification
    warning LNK4197: export 'DllGetActivationFactory' specified multiple times; using first specification
    warning LNK4197: export 'DllCanUnloadNow' specified multiple times; using first specification
    error LNK2005: _DllCanUnloadNow@0 already defined in dllmain.obj
    error LNK1169: one or more multiply defined symbols found

    Comment out DllCanUnloadNow will produce runtime error.

    I get a runtime break at

    // GrayscaleTransform.dll!Microsoft::WRL::Details::ModuleBase::ModuleBase()  Line 155 + 0x46 bytes  C++

        ModuleBase() throw()
        {
    #ifdef _DEBUG
            // This indicates that there were two instances of the module created or race conditon during module creation
            // If you are creating object with new/delete please make sure that you haven't created more than one module
            // and you disabled static initalization with __WRL_DISABLE_STATIC_INITIALIZE__
            // otherwise please initialize/create module in main()
            __WRL_ASSERT__(::InterlockedCompareExchangePointer(reinterpret_cast<void* volatile*>(&module_), this, nullptr) == nullptr &&
                "The module was already instantiated");

            SRWLOCK initSRWLOCK = SRWLOCK_INIT;
            __WRL_ASSERT__(reinterpret_cast<SRWLOCK*>(&moduleLock_)->Ptr == initSRWLOCK.Ptr && "Different value for moduleLock_ than SRWLOCK_INIT");
            (initSRWLOCK);
    #else
            module_ = this;
    #endif
        }



    Tuesday, October 16, 2012 8:56 AM

Answers

  • Hi all, I manage to solve my problem with the advice from here :

    http://stackoverflow.com/questions/12893355/windowsstorageapplicationdatacurrent-not-found-in-c

    Wednesday, October 17, 2012 9:59 AM

All replies

  • For Windows Store Apps (Metro) project configuration should be

    Runtime library = Multi-threaded dll(/MD) or Multi-threaded Debug dll (/MDd)
    Metro Style App Support = Yes
    Consume Windows Runtime Extension = Yes(/ZW)

    Tuesday, October 16, 2012 12:20 PM
  • Hi,

    I guess the Windows.winmd is not included into your project.
    Please add this Macros to C/C++->General->Additional #using Directories
    $(WindowsSDK_MetaDataPath)

    Also you need to add platform.winmd for C++/CX
    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\Microsoft.VCLibs\
      11.0\References\CommonConfiguration\neutral

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, October 17, 2012 7:12 AM
  • Hi all, I manage to solve my problem with the advice from here :

    http://stackoverflow.com/questions/12893355/windowsstorageapplicationdatacurrent-not-found-in-c

    Wednesday, October 17, 2012 9:59 AM