DirectXTK and Windows 8

Jan 8, 2013 at 3:39 PM

Hi All,

Has anyone managed to make use of the toolkit on a windows 8 store application? I'm having several issues. In short, I used the C#/C++ Media capture using capture device sample provided by Microsoft. Out of the box, the sample contains a C# XAML presentation project and a C++ WinRT project that inherits from the IMFTransform.

Next, I added the DirectXTK_Windows8 project to the solution and referenced it in the C++ project. I added a few methods to make sure the reference work without actually calling them. This is where I started running in problems:

  1. The application would not build, complaining about DirectXTK.winmd. To correct this I applied the changes specified in this post and manually edited the pre-processor and linker properties of the WinRT C++ library.
  2. The next problem I encountered is the following error message: "error LNK2005: DllCanUnloadNow already definied in dllmain.obj". This issue was described in detail here. It seems it's due to conflicting definitions. I applied the suggested fix in pre-processor and linker.
  3. The application finally build and ran ok initially. When I invoked the modified WinRT dll (which does not call any new logic though) I got a cryptic "Error in the DLL" exception, without any additional detail. At this point I'm stuck trying to find out how to resolve it.

Any suggestions on how to troubleshoot this or working examples of a Windows 8 store application that use DirectXTK are most welcome.

Many thanks,

Stefan

 

 

 

 


Coordinator
Jan 8, 2013 at 6:26 PM
Edited Jan 8, 2013 at 6:27 PM

I've got a simple test sample to use it very easily, but I started with the Direct3D App template. Have you tried doing that? I suspect the project you are using a bit more complicated than the minimum needed to get it working.

I have added some specific instructions to the docs on how to add it to a VS project.

Jan 21, 2013 at 7:53 PM
Edited Jan 21, 2013 at 8:16 PM

Thanks,

I tried following the instructions as well as a few other things but it didn't help. I did some more debugging and managed to trace the issue further. In short, I have a dummy method which is not called but it resides in the Windows Runtime Component. Another method in this component is called by the C#/XAML UI. The dummy method has some code to instantiate an effect but again, this code is not called at all. The following line is causing all the grief:

m_spriteBatch->Begin(); //m_spriteBatch is a SpriteBatch instance

As soon as I invoke the DLL that contains this line,  the application crashes with the error below. If I remove this one line of code, the application runs correctly.
The error I get when I attach a debugger is: "MediaCapture.exe has triggered a breakpoint". Even though I haven't added that breakpoint it is in the "implements.h" file, in the following method:

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
    }

The breakpoint is at the __WRL_ASSERT__ line. Any thoughts on what could be causing this? I found a few articles online but none seem to resolve the issue.

 For example, I found the exact same problem here but the resolution steps described doesn't help me.

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

Let me know if this forum isn't the correct place for this question. I figured since the error happens when I call SpriteBatch->Begin(); you might've seen this issue before.

Thanks in advance,
Stefan