none
WinRT component works in C#, but not in C++ RRS feed

  • Question

  • I have a C# WinRT Component that works when I call it from C#, but now that I'm trying to call it from C++, it crashes.

    Exception thrown at 0x00007FFE5717A839 in Samples.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x000000A7E9FFECC0. HRESULT:0x80131040 The text associated with this error code could not be found.
    WinRT information: The text associated with this error code could not be found.

    All it does is create DirectX device and resources.

    Edit:

    Also related is an additional issue - I cannot debug the runtime component when running the C++ app. See below for my efforts to get it working. I cannot either step into library code at execution time, nor can I even do things like 'Go To Definition' of a library function, as though Visual Studio can't see the runtime component at all. I don't have these issues when using the library from a C# project.
    Thursday, September 5, 2019 7:51 AM

All replies

  • Hi,

    Could you please tell me what kind of project you are using? Is it uwp?

    Best Regards,

    Jeanine Zhang

    Thursday, September 5, 2019 9:35 AM
  • Yes, the DirectX 11 template project is the Universal Windows one.

    Any suggestions about getting debug output or stepping into the WinRT component would help too. I'm not very experienced with C++ so I might be missing strategies to get to the bottom of what's wrong. For instance, can I force symbols to be associated/loaded for the WinRT component so that i can breakpoints in there?

    Thursday, September 5, 2019 10:01 AM
  • Hi,

    Do you mean when your DirectX 11 template project calls C# WinRT Component, it crashes? How did you call it from C++? Since this error has no way to locate what caused it, so can you please provide a simple that can be reproduced? In addition, about loading Symbol, you can refer to this document.

    Best Regards,

    Fay


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 6, 2019 5:54 AM
  • "How did you call it from C++?" - I think you're asking - how did I call the C# WinRT component from C++ ? Could you pls clarify because I don't think I understand. The straight forward answer is .. I called it like this ..

    1. I  included the reference for the C# WinRT Component.
    2. I declared that I was using the namespace for the class in the component.
    3. I called the constructor on the class.
    m_bitmap = ref new BitmapRenderer(); // << this fails
    I tried building the library in both debug and release with the same result.

    In regards to the symbol loading. I read this .. 

    "When you debug a project in the Visual Studio IDE, the debugger automatically loads symbol files that are located in the project folder."

    and ..

    "By default, if you have built a DLL or an .exe file on your computer, the linker places the full path and filename of the associated .pdb file in the DLL or .exe file. The debugger checks to see if the symbol file exists in that location."

    So according to that page you linked, I shouldn't have to do anything. Both the application and the library projects are in the same solution. And other libraries debug correctly, this is the first time I've had one of my libraries not debug - is it because it's a Windows Runtime Component library?

    Edit: I can provide the solution, but It'll have to be tomorrow, It's getting really late now.

    Note: I'm not actually using any of the DirectX stuff in the template - i just use that template because it sets up CoreWindow the way I want, and saves me a bit of work.

    Saturday, September 7, 2019 3:13 PM
  • 1) I enabled 'Managed and Native' debugging - but then I can't even set a breakpoint in native code and I still get the exception. So that setting seems to do the very opposite of what it's meant to do.

    2) I also tried disabling just my code to no effect.

    3) I enabled Microsoft Symbol Server - upon stepping into the code, I end up here ..

    namespace __winRT
    {
    	long __stdcall __getActivationFactoryByPCWSTR(void* str, ::Platform::Guid& pGuid, void** ppActivationFactory)
    	{
    		return GetActivationFactoryByPCWSTR(str, pGuid, ppActivationFactory);
    	} // <<< HERE
    }
    With the following output ..

    Exception thrown at 0x00007FFE5717A839 (KernelBase.dll) in AppCppCx.exe: 0x04242420 (parameters: 0x0000000031415927, 0x00007FFDD2940000, 0x00000062035FD490).
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00000062035F9828.
    onecore\com\combase\objact\dllcache.cxx(4713)\combase.dll!00007FFE590FE9F2: (caller: 00007FFE5901819A) ReturnHr(1)
    
    tid(510) 80131040 


    Then the next F11 step I end up here ...

    VCCORLIB_API __declspec(noreturn) inline void __stdcall __abi_WinRTraiseCOMException(long hr)
    {
    throw ::Platform::Details::ReCreateException(hr); // << Exception
    }


    With the following Exception (the one that i see without symbols loaded by the looks of it.

    Exception thrown at 0x00007FFE5717A839 in AppCppCx.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x00000062035FEDE0. HRESULT:0x80131040 The text associated with this error code could not be found.
    WinRT information: The text associated with this error code could not be found.

    4) I used Tools > Import & Export Settings > Reset all settings - to no effect.

    Sunday, September 8, 2019 1:30 AM
  • Hi Fay,

    Here's a OneDrive share to the zipped solution.

    Shared Sln

    It contains ..

    AppCppCx - A C++/CX UWP application that uses WinRTComponentCS

    AppCS - A C# UWP application that uses WinRTComponentCS

    WinRTComponentCS - A C# Windows Runtime Component that uses SharpDX to create DirectX device + swapchain and clears swapchain to XNA's classic cornflower blue.

    You can see that the C# app (AppCS) runs and works, I can also step into the library. This is probably expected as both library and application are C# in this case. But when the C++ app (AppCppCx) is started, it fails to create the bitmapRenderer class and cannot step into the library.

    Edit: In fact, I can't even 'go to definition' in source. Instead the object browser is brought up. So the C++ project can't even see the library at all.





    Sunday, September 8, 2019 4:39 AM
  • Hi,

    Sorry for my delay. I will ask other engineers for help.

    Best Regards,

    Fay


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 11, 2019 2:48 AM