none
Loading RunTime Component dynamically RRS feed

  • Question

  • According to 

    https://social.msdn.microsoft.com/Forums/en-US/bf23cd34-ef61-4354-b34b-ff21bd7a4f7c/windows-8-and-assemblyloadfrom?forum=winappswithcsharp

    I like to load dynamically RunTimecomponent in my application. According to above post we can’t. This post is 5 years old. I am not sure if still it is true.  I don’t want to include the RunTime Component in manifest.

    Regards


    Agha Khan

    Wednesday, November 8, 2017 5:57 AM

All replies

  • The post doesn't say you cannot load an assembly dynamically.

    You can off course load an assembly dynamically using Assembly.Load(AssemblyName). Check this for details https://msdn.microsoft.com/en-us/library/x4cw969y(v=vs.110).aspx  

    Friday, November 10, 2017 11:07 AM
  • Thank you Sezhiyan:

    As you know RunTime components don't produce Dll, rather produces xbf type file, so Assembly.Load doesn't apply. 

    Best regards

    Agha


    Agha Khan

    Friday, November 10, 2017 4:27 PM
  • Hi , 

    You can load any assembly , create instance of a classe , get all members and properties .

    Assembly.Load("Name") ,LoadFile(@"c:\xxx.dll") or LoadFrom()

    Type type = Type.GetType("TypeName", true);
    object instance = Activator.CreateInstance(type);
    PropertyInfo prop = type.GetProperty("PropertyName");
    prop.SetValue(instance, value, null);

    Saturday, November 11, 2017 12:09 AM
  • Thank you Omid:

    As I explained above RunTime components don't produce Dll, so we can't use Assembly.Load("Name")

    Thanks for your reply.


    Agha Khan

    Saturday, November 11, 2017 2:51 AM
  • Hi Agha,

    By xbf if you are are referring to XamlBinaryFiles, then you should be able to read/load them using the XamlReader class ( https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Markup.XamlReader ), right ?

    Regards,
    Sezhiyan

    Monday, November 13, 2017 8:46 AM