小编Dim*_*nyi的帖子

在JObject层次结构中按名称搜索特定的JToken

我有一些来自服务器的Json响应,例如:

{"routes" : [
  {
     "bounds" : {
        "northeast" : {
           "lat" : 50.4639653,
           "lng" : 30.6325177
        },
        "southwest" : {
           "lat" : 50.4599625,
           "lng" : 30.6272425
        }
     },
     "copyrights" : "Map data ©2013 Google",
     "legs" : [
        {
           "distance" : {
              "text" : "1.7 km",
              "value" : 1729
           },
           "duration" : {
              "text" : "4 mins",
              "value" : 223
           },
Run Code Online (Sandbox Code Playgroud)

我想从中获取令牌'text'的值

      "legs" : [
        {
           "distance" : {
              "text" : "1.7 km",
              "value" : 1729
           },
Run Code Online (Sandbox Code Playgroud)

这是一个值为"1.7 km"的字符串.

问题: …

c# json json.net

34
推荐指数
3
解决办法
5万
查看次数

加载程序集时依赖于另一个域的FileNotFound

我正在尝试使用插件进行应用程序.

我有MainLib.dll,我ICommon用1方法制作了一些commnon接口(让它成为).然后,我制作了2个.dll(插件),它们引用了MainLib.dll并ICommon在某些类中实现了.另外,我删除了这个.dll exept中的所有引用System.

然后,我创建了一个应用程序,它监视文件夹".\\Plugins"并加载所有.dll newDomain,检查.dll中的类型是否实现ICommon(因此该应用程序也引用MainLib.dll).如果是 - 在某些列表中添加.dll的名称.

现在问题出现了:在我尝试加载插件之前 - 我将MailLib.dll和System加载到newDomain,因为所有插件都依赖于此.dll.他们加载正确.然后,我开始加载插件,在这里我有:

FileNotFoundException,无法加载文件或程序集'PluginWithException,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一.系统找不到指定的文件.)字符串Assembly loadedAssembly = domain.Load(Assembly.LoadFrom(asm).FullName);

PluginWithException程序集只有2个依赖项--System和MainLib.在我尝试加载PluginWithException之前,我检查了新域中的程序集,System和MainLib已加载到此域.所以我看不到任何依赖的问题.我读了这个主题,尝试了解决方案,ProxyDomain但异常是一样的.

我做错了什么?

这里的代码:

public static List<string> SearchPlugins(string[] names)
{
    AppDomain domain = AppDomain.CreateDomain("tmpDomain");
    domain.Load(Assembly.LoadFrom(@".\MainLib.dll").FullName);
    domain.Load(@"System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
    MessageBox.Show(GetAssembies(domain)); // here I can see that System and MailLib exist in new domain

    List<string> plugins = new List<string>();

    foreach (string asm in names)
    {
        Assembly …
Run Code Online (Sandbox Code Playgroud)

c# plugins appdomain .net-assembly

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

当另一个域抛出异常时应用程序崩溃

我正在学习C#。我阅读了 Andrew Troelsen 的《C# and the .NET Platform》和 Jeffrey Richter 的《CLR via C#》等书。现在,我正在尝试创建应用程序,它将从某个目录加载程序集,将它们推送到 AppDomain 并运行包含的方法(支持插件的应用程序)。这是 DLL,其中是公共接口。我将其添加到我的应用程序以及所有带插件的 DLL 中。主库.DLL

namespace MainLib
{
public interface ICommonInterface
{
    void ShowDllName();
}
}
Run Code Online (Sandbox Code Playgroud)

这是插件:PluginWithOutException

namespace PluginWithOutException
{
public class WithOutException : MarshalByRefObject, ICommonInterface
{
    public void ShowDllName()
    {
        MessageBox.Show("PluginWithOutException");
    }

    public WithOutException()
    {

    }
}
}
Run Code Online (Sandbox Code Playgroud)

另一个:PluginWithException

namespace PluginWithException
{
public class WithException : MarshalByRefObject, ICommonInterface
{
    public void ShowDllName()
    {
        MessageBox.Show("WithException");
        throw new NotImplementedException();
    }
}
}
Run Code Online (Sandbox Code Playgroud)

这是一个应用程序,它加载 DLL 并在另一个 AppDomain 中运行它们

namespace …
Run Code Online (Sandbox Code Playgroud)

c# exception appdomain .net-assembly

0
推荐指数
1
解决办法
2592
查看次数

我可以获得BIOS日期和时间吗?

我有一个脚本,它监视一些文件夹的子文件夹,检查它们的创建日期,如果DateDiff来自创建的时间,而现在是超过730(2年),它会删除这个文件夹.问题在于,如果在2015年5月16日在PC上设置当前时间 - 脚本将删除文件夹,这并不酷.我想从一些互联网服务中获取时间,但无法保证PC将连接到互联网.所以我试图获得BIOS时间(我相信没有用户可以将其更改为错误),并将文件夹的创建时间与此时间进行比较.但是,遗憾的是我没有找到如何做到这一点的方式.也许你知道如何实现这个任务?

vbscript

-1
推荐指数
1
解决办法
1399
查看次数

标签 统计

c# ×3

.net-assembly ×2

appdomain ×2

exception ×1

json ×1

json.net ×1

plugins ×1

vbscript ×1