locked
Why my C# Metro App project not able to reference WinRTComponentDll

    Question

  • Is this allowed?

    Here is my experiment

    1. Created simple C# metro style app

    2. Created WinRTComponentDll in the same solution

    3. Compiled both

    4. Try to add WinRTComponentDll as reference in my C# project, it does not let me do it.

    But

    I tried the same steps mentioned above with JavaScript project, it works,  (in step-1 created JS project)

    So does this mean we can not use WinRTExtensions in C# project, this can not be true, I am missing something here.

    I referenced the document, I used C# project in stead of JavaScript.

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441569(v=VS.85).aspx

     

    Also tried this approach mentioned here

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/d42b9faa-cd2e-4280-abd6-aed75bb6897f

    this lets me add the reference but gives me error

    Error 1 The type 'Platform.IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'platform, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'. C:\..\Projects\TestCSharpApp\TestCSharpApp\MainPage.xaml.cs 18 13 TestCSharpApp

    Looks to be a setup issue with platform dependent stuff.




    • Edited by __PB Wednesday, October 5, 2011 9:56 PM
    Wednesday, October 5, 2011 7:34 PM

Answers

  • I assume WinRTComponentDll is  C++ project. If so, there's a bug in the preview version. You need to add the reference before you build the Dll. If you've built it already, do a clean, add the reference, and then rebuild all.
    http://blog.voidnish.com
    Wednesday, October 5, 2011 9:21 PM
  • Finally was able to get it compiled and debug only C# part. Here is what I did (may not be very efficient way, my task was finding a way to compile + debug)

    1. Created simple C# metro style app

    2. Created WinRTComponentDll in the same solution

    3. Add WinRTComponentDll as reference in my C# project.

    4. Compile the whole solution. Now you your 'WinRTComponentDll' reference shows a warning icon (this means something fishy here, for sure there is), not sure whether you get that 'Platform.IDiposable' error I mentioned above.

    5. Add another reference to your C# project. This is 'Microsoft.VCLibs'

    6. Now it compiles try to debug (you should see some deployment issue)

    7. Go to your C# project properties modify 'Platform Target -> 0x86' (I assume you are using x86 system). This is where I think MSFT is still silent about and may be they are finding nice solution. As people are speculating it as a bug I do not think it is a bug, this feature is not enabled yet :)

    8. Now try debugging it should work, but I was not able step into my C++ win RT code. May be there is some setting out there.

    It was fun though

    PB


    Wednesday, October 5, 2011 10:19 PM

All replies

  • I assume WinRTComponentDll is  C++ project. If so, there's a bug in the preview version. You need to add the reference before you build the Dll. If you've built it already, do a clean, add the reference, and then rebuild all.
    http://blog.voidnish.com
    Wednesday, October 5, 2011 9:21 PM
  • Finally was able to get it compiled and debug only C# part. Here is what I did (may not be very efficient way, my task was finding a way to compile + debug)

    1. Created simple C# metro style app

    2. Created WinRTComponentDll in the same solution

    3. Add WinRTComponentDll as reference in my C# project.

    4. Compile the whole solution. Now you your 'WinRTComponentDll' reference shows a warning icon (this means something fishy here, for sure there is), not sure whether you get that 'Platform.IDiposable' error I mentioned above.

    5. Add another reference to your C# project. This is 'Microsoft.VCLibs'

    6. Now it compiles try to debug (you should see some deployment issue)

    7. Go to your C# project properties modify 'Platform Target -> 0x86' (I assume you are using x86 system). This is where I think MSFT is still silent about and may be they are finding nice solution. As people are speculating it as a bug I do not think it is a bug, this feature is not enabled yet :)

    8. Now try debugging it should work, but I was not able step into my C++ win RT code. May be there is some setting out there.

    It was fun though

    PB


    Wednesday, October 5, 2011 10:19 PM
  • The Express edition does not allow you to specify mixed-mode debugging. You can try this though, run the C# executable directly from Metro (and not from within VS 11). Now use debug/Attach to process and specify native + managed, and attach to the executable. Hit break. Or set breakpoints in event handlers.
    http://blog.voidnish.com
    Wednesday, October 5, 2011 10:55 PM
  • [message about non-public version deleted]

    These forums are for discussion only of the public Developer Preview. If you have access to newer builds then please do not post here. Please address any questions through the channel from which you received the newer build.



    Friday, February 10, 2012 7:37 AM
  • I tried devoloping in VB got the same error what should I do ?

    Jithu R Jacob

    Friday, May 11, 2012 10:29 AM
  • http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/9692dc39-7417-4a1e-a6ab-c607799c6750

    This is the error I am getting on VB Is there a solution ?


    Jithu R Jacob

    Friday, May 11, 2012 10:38 AM