peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

How to load a xaml from external dll

01 Apr 2022, 13:28

The external dll (Buttons.dll) includes xaml and cs file
1648811878(1).png
And

The login load the referenced assembly before loading the xaml
1648811903(1).png
I think Assembly.LoadFile is effective

but it can't show the CustomView UI. So how to resolve this issue?
1648811915(1).png
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: How to load a xaml from external dll

04 Apr 2022, 13:04

In your App class you have to override the CreateXamlProvider to return a xaml provider that can load resources from all your assemblies. By default we provide the EmbeddedXamlProvider class that can chain several providers, for example you can do something like this:
partial class App : Application
{
  ...
  protected override XamlProvider CreateXamlProvider()
  {
    XamlProvider buttonsProvider = new EmbeddedXamlProvider(Assembly.Load("Buttons"), "Buttons");
    
    Type type = this.GetType();
    return new EmbeddedXamlProvider(type.Assembly, type.Namespace, buttonsProvider);
  }
}
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: How to load a xaml from external dll

06 Apr 2022, 02:57

thx, it works for me
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: How to load a xaml from external dll

06 Apr 2022, 11:01

Hi, i try it by Android platform. The Buttons.dll is build file of Buttons-android at ManagerSDK. Their build settings is same, but i get the error
1649235579(1).png
So how to resolve this issue?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: How to load a xaml from external dll

11 Apr 2022, 12:51

Hi,

The libraries included in the ManagedSDK are xamarin applications and cannot be loaded that way.
The external library should be defined as a Class Library (.netstandard 2.0) and depend on Noesis.GUI for defining your user controls.

Could you tried that?
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: How to load a xaml from external dll

12 Apr 2022, 11:04

Thx for your reply, i loaded a .netstandard2.0 class library and have the same issue
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: How to load a xaml from external dll

12 Apr 2022, 15:59

Is the class library referenced in the application?
Expand the application project in Visual Studio, right-click on References and select "Add Reference...", then select the class library project.
Otherwise the library won't be included in the android package when building and deploying.
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: How to load a xaml from external dll

13 Apr 2022, 03:35

Is the class library referenced in the application?
Expand the application project in Visual Studio, right-click on References and select "Add Reference...", then select the class library project.
Otherwise the library won't be included in the android package when building and deploying.
but i want to load the class library from storage in android device, please take a look at the screenshot I provided above
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: How to load a xaml from external dll

15 Apr 2022, 05:54

ok, i fixed this issue. Permission Denied
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to load a xaml from external dll

15 Apr 2022, 16:12

Great! Thanks for the feedback

Who is online

Users browsing this forum: Semrush [Bot] and 84 guests