locked
Loading WRT class inside C# (also WRT)

    Question

  • First,

    1) I know this forum could not be the best choose but I didn't find any better on msdn

    2) I know this is not a way to build proper windows store apps

    now question:

    In most cases, adding new library is simple. Programmer just choose proper winmd file or create new solution which could be added as reference.

    But imagine that you have only dll (unmanaged, registered in system registry which expose DllGetActivationFactory, and rest of important Dll*), you know class structure which is inside this library, you also know UUID. You do not have code and idl, tlb, winmd.
    Using C++ you could use RoInitialize etc. function and of course probably this also could be done in "normal" .NET app. But how could this object be created in WinRT app ? Logical should by simple as adding UUID parameter to class and "everything should work", but of course it is not so simple. How could be realized namespace (because in winmd you already have it, when you declare class in your file, should you add proper namespace ). Have you any ideas ?

    Another question, is there a possibility to browse such COM object (such a normal com object which exposed DllGetClassObject).

    Best regards
    Bartosz

       
    Saturday, March 21, 2015 5:11 PM

All replies

  • Hi Bartosz,

    >> Using C++ you could use RoInitialize etc. function and of course probably this also could be done in "normal" .NET app. But how could this object be created in Windows Runtime App?

    I guess what you mean by “normal .NET App” is the desktop Windows .NET application which could invoke external C++ dynamic link library. But I’m afraid Windows Runtime App is a different from the desktop application.

    According to your description, I think your first question is:

    Is it possible to load WRT class inside C# pragmatically in Windows Runtime App?

    The Windows Runtime C++ Template Library (WRL) is a template library that provides a low-level way to author and use Windows Runtime components, but I’m afraid we don’t have such library in C#.

    To use the class library in your Windows Runtime App in C#, instead of loading it in C# pragmatically, I will suggest you referencing the Windows Runtime Component in the Window Runtime App Project.

    >> is there a possibility to browse such COM object

    Based on my understanding, Windows Runtime is the COM based technology, all of the Windows Runtime classes would implement the IInspectable interface, but I think it will be very complex to browse it.

    (Please correct me if I have any misunderstandings)

    Hope it will help.

    Regards,

    Jeffrey


    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.

    Monday, March 23, 2015 10:59 AM
  • If I understand it correctly you are trying to use a Win32 based COM-object from a WinRT App? As far as I remember this is not possible. It is however possible in Non-Store WinRT Apps to use Brokered Windows Runtime components which basically launch a service in the Win32 world that provides data to the WinRT App. The topic is described here: https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx?f=255&MSPPError=-2147217396

    As is stated there this is only intended for .Net applications but the Desktop side of the .Net code can access regular COM components.

    Monday, March 23, 2015 1:14 PM
  • Thank you for your answers.

    Olivier,

    No, Jeffrey understanding of my problem is better. I would like to load WinRT dll library but having only this library. I know that I could reference it using winmd but as mention by Jeffery, in C++ I could use dynamic loading (using Ro* functions). But why I couldn't do that under C#-winrt, wher I not have also dllimport (and this is OK in sens of this type of application). Can not be combined with safety, because dll must be registered, from this point of view we do not do something wrong in sense of winrt.

    Overall my question could be also formulated as: "How could be generated winmd for C#-WinRT file for winrt-com dll"

    Jeffrey,

    view - something like oleview. But in this case this is a second problem. As I mention I know class structure, I know UUID, library is registered.


    What I see now is to build C++/winrt wrapper for loading class and use it under winrt-c# app, but this still not solve some problems from my question (how namespace is embeded in winmd, because it could not be embedded at the COM, we get only pointer to  IInspectable->IUnknown.

    @Jeffrey

    I will suggest you referencing the Windows Runtime Component in the Window Runtime App Project.

    yes, this is solution. But i need winmd or source what to do if I not have or have only interfaces/view of class (in normal com -  object, this situation was not a problem, normal com mean that as base interface was not IInspectable derived from IUnknown but IUnknown or IDispatch with DllGetClassObject exposed) ?

    Monday, March 23, 2015 10:44 PM