[UWP] Windows 10的WinJS和WinRT:无法加载依赖项或程序集 [英] [UWP]WinJS and WinRT for windows 10 : Fail to load dependencies or assemblies
问题描述
我是C#和WinJS开发的新手。我正在尝试开发一个使用WinJS的通用应用程序,并在WinRT组件中调用一些C#代码。
I'm new in C# and WinJS development. I'm trying to develop an universal app wich use WinJS and call some C# code in a WinRT component.
我在WinRT组件中使用第三部分库,我有一些问题,每次我想要使用它失败了。应用程序向我发送如下异常:
I have some problems with using third parts librairies in WinRT component, everytime i want to use them it fail. The application send me an exception like this :
System.IO.FileNotFoundException: Could not load file or assembly 'XXXXX, Version=X.X.X.X, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
我对可以使用WinRT组件的库有这个问题(例如m2mqtt或tweetinvi)。我使用VS 2015,所有的库都由nuget管理。
I have this problem with libraries that can work with WinRT components (for exemple m2mqtt or tweetinvi). I work with VS 2015 and all librairies are managed by nuget.
我只是在JS中调用这样的WinRT类(main.js是VS在WinJS解决方案中创建的默认文件):
I simply call WinRT classes like this in JS(main.js the default file created by VS in a WinJS solution):
function goal() {
var run = new SocialComponant.Running();
var run = new SocialComponant.Running();
}
在C#部分,这是一个简单的调用(例如m2mqtt)
In C# part it's a simple call (exemple with m2mqtt)
public Running() {
MqttClient client = new MqttClient(BROKER);
MqttClient client = new MqttClient(BROKER);
client.MqttMsgPublishReceived + = Client_MqttMsgPublishReceived;
client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
client.Connect(ID);
client.Connect(ID);
client.Publish(" / test",Encoding.UTF8.GetBytes(" Message test"));
client.Publish("/test", Encoding.UTF8.GetBytes("Message test"));
client.Disconnect();
client.Disconnect();
}
我从来没有设法看到fuslogvw.exe的依赖问题,所以我不确定发生了什么。
I never managed to see dependencies problem with fuslogvw.exe so I am not really sure about what is going on.
感谢您的帮助
推荐答案
您好k3ym91,
Hi k3ym91,
从您发布的代码来看,似乎Running不是静态方法。我们无法通过 bsp; 来自SocialComponant.Running()。
From you code that you post, it seems the Running is not a static method. That we can not use the Running method by SocialComponant.Running().
有一个关于如何创建简单Windows运行时组件并从JavaScript调用它的官方文档,请请参阅此链接: https://msdn.microsoft.com/en-us/windows/uwp/winrt-components/walkthrough-creating-a-simple-windows-runtime-component-and-calling-它来自javascript 。
There is an official document about how to create a Simple Windows Runtime component and calling it from JavaScript, please refer it in this link: https://msdn.microsoft.com/en-us/windows/uwp/winrt-components/walkthrough-creating-a-simple-windows-runtime-component-and-calling-it-from-javascript.
您也可以分享一个简单的转载项目,它将帮助我们更清楚地分析和诊断这个问题。
Also would you please share us a simple reproduced project, it will help us analyze and diagnose this issue more clearly.
最好的问候,
Jayden Gu
Jayden Gu
这篇关于[UWP] Windows 10的WinJS和WinRT:无法加载依赖项或程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!