小编End*_*DAG的帖子

可重用的内容视图 .NET MAUI

简而言之,我有一个内容视图,例如;

<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="myapp.customstacklayout">
    <StackLayout>


        <StackLayout>
            <StackLayout x:Name="header">

                <!-- some title things here, such as a header label etc-->

            </StackLayout>
            <StackLayout x:Name="content">

                <!--Contents should be added here when reused-->


            </StackLayout>
            <StackLayout x:Name="footer">

                <!-- some footer things here, such as a summary label etc-->

            </StackLayout>
        </StackLayout>

        <!--Not here-->

    </StackLayout>
</ContentView>
Run Code Online (Sandbox Code Playgroud)

我想在 ContentPage 中重用它,例如;

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:mycontrols="clr-namespace:myapp"
             x:Class="myapp.mainpage">

    <StackLayout>
        <mycontrols:customstacklayout>

            <Button Text="TestButton"/>
            <Entry Text="TestEntry"/>
            <Label Text="TestLabel"/>
                .... and etc..

        </mycontrols:customstacklayout>
    </StackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

要创建这样一个可重用的项目,我认为,在 xaml 中,必须有一些内容让 contentview 指出应该将子项添加到哪个 IView 项目中

有什么想法或一段代码吗? …

xaml xamarin maui contentview

4
推荐指数
1
解决办法
4455
查看次数

C# 避免在 Assembly.Load 时锁定文件

我的情况是;

我正在设计一个插件应用程序,基于动态加载插件程序集,多个用户可以运行托管在服务器机器上的应用程序。应用程序在启动时从我的实时更新服务器自动更新插件程序集。所以插件文件(及其附属 dll 不应该被锁定在文件系统上。

 byte[] assemblyBytes = File.ReadAllBytes("asm-path");
 var assembly = Assembly.Load(assemblyBytes);
Run Code Online (Sandbox Code Playgroud)

正如预期的那样没有锁定 dll 文件。但是如果我正在加载的 dll 本身具有静态引用 dll 呢?他们现在被锁定在文件系统上。

命名文件,让我们说;

  • APP.Exe 是我的基础应用程序;
  • PL1.dll 是我的第一个插件,APP.exe 将它加载到一个新的 Appdomain
  • PL2.dll 是我的第二个插件,APP.exe 将它加载到一个新的 Appdomain 中
  • PL1_S.dll 是 PL1.dll 插件的静态引用 dll,加载在 PL1 AppDomain 中
  • PL_COMMON 是 PL1 和 PL2 插件的静态引用 dll,由 PL1 和 PL2 AppDomains 加载

PL1_S 和 PL_COMMON 也不应该像 PL1 和 PL2 程序集那样被锁定在文件中

关于如何解决这个问题的任何想法?

c# dll filelock .net-assembly

2
推荐指数
1
解决办法
2985
查看次数

标签 统计

.net-assembly ×1

c# ×1

contentview ×1

dll ×1

filelock ×1

maui ×1

xamarin ×1

xaml ×1