UWP FullTrustProcess 无法加载 dll
UWP FullTrustProcess can't load dll
我使用 uwp 和 winforms 项目作为完全信任进程。在 winF 项目中,我通过 NuGet 添加了对 Dotras.dll 的引用。 Dll 已添加到引用中,一切看起来都正常,直接从 winforms 启动效果很好。
但是当启动 UWP 并调用 fullTrustProcess 时(连接正常,消息已发送)并尝试调用 Dotras.dll 抛出异常。
Could not load file or assembly 'DotRas, Version=1.3.5166.33435, Culture=neutral, PublicKeyToken=b378f04384b7892a' or one of its dependencies. The system cannot find the file specified.
我试过向 UWP 项目添加引用,但它不允许,因为目标是 .net 核心,而 DotRas 是 .net 框架。
任何提示将 dll 放在哪里以使其工作?谢谢!
确保exe和dll部署到同一个文件夹。
方法如下。
打开Visual Studio中的项目,有一个Assets
文件夹,一般是用来存放logo图片的。
把exe和dll都放到这个文件夹里,右击文件夹,在菜单里选择select "Add New Item",把它们的Build Action
设为Content
,因此在应用程序部署期间,它们将被复制到 C:\Program Files\WindowsApps\YouPackageFamilyName\
中的安装目录,位于相同的 Assets
文件夹下。
在appxmanifest文件中,确保可执行路径是正确的。
<desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\YourWinForms.exe">
</desktop:Extension>
编辑:不一定是Assets文件夹,关键是将dll添加到项目中Build Action
设置为Content
并放在与exe相同的文件夹中。
我使用 uwp 和 winforms 项目作为完全信任进程。在 winF 项目中,我通过 NuGet 添加了对 Dotras.dll 的引用。 Dll 已添加到引用中,一切看起来都正常,直接从 winforms 启动效果很好。 但是当启动 UWP 并调用 fullTrustProcess 时(连接正常,消息已发送)并尝试调用 Dotras.dll 抛出异常。
Could not load file or assembly 'DotRas, Version=1.3.5166.33435, Culture=neutral, PublicKeyToken=b378f04384b7892a' or one of its dependencies. The system cannot find the file specified.
我试过向 UWP 项目添加引用,但它不允许,因为目标是 .net 核心,而 DotRas 是 .net 框架。 任何提示将 dll 放在哪里以使其工作?谢谢!
确保exe和dll部署到同一个文件夹。
方法如下。
打开Visual Studio中的项目,有一个Assets
文件夹,一般是用来存放logo图片的。
把exe和dll都放到这个文件夹里,右击文件夹,在菜单里选择select "Add New Item",把它们的Build Action
设为Content
,因此在应用程序部署期间,它们将被复制到 C:\Program Files\WindowsApps\YouPackageFamilyName\
中的安装目录,位于相同的 Assets
文件夹下。
在appxmanifest文件中,确保可执行路径是正确的。
<desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\YourWinForms.exe">
</desktop:Extension>
编辑:不一定是Assets文件夹,关键是将dll添加到项目中Build Action
设置为Content
并放在与exe相同的文件夹中。