我有一个JObject,我想从一个强类型对象设置属性.
JObject["ProductionVersion"] = new ProductionVersion();
Run Code Online (Sandbox Code Playgroud)
为此,需要将ProductVersion转换为JToken.如何在不必将对象序列化和反序列化为JObject的情况下执行此操作?
JObject["ProductVersion"] = JsonConvert.DeserializeObject<JObject>(JsonConvert.SerializeObject(message.ProductVersion))
Run Code Online (Sandbox Code Playgroud) 我为我的服务器配置了自动启动功能,如下所示:
http://msdn.microsoft.com/en-us/library/ee677260(v=azure.10).aspx
我没有使用自定义方法,因为我不需要做任何预热,
我只是将应用程序池设置为自动启动,将serviceAutoStartEnabled设置为true的应用程序.
<add name="PluckBuildServer" managedRuntimeVersion="v4.0" startMode="AlwaysRunning">
<application path="/" applicationPool="PluckBuildServer" serviceAutoStartEnabled="true">
Run Code Online (Sandbox Code Playgroud)
显然,这还不足以启动Ninject用来启动的WebActivator.有关如何获得这项工作的任何想法?另请注意,我真的需要能够使用PowerShell编写所有这些脚本.
这是我在Ninject App_Start类中的WebActivator行:
[assembly: WebActivator.PreApplicationStartMethod(typeof(Pluck.Build.Server.App_Start.NinjectWebCommon), "Start")]
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助.
我无法获得Visual Studio 2012 RTM的Xunit测试运行器扩展来加载我的x64混合模式程序集.
错误是:System.IO.FileLoadException:混合模式程序集是针对运行时的版本"v2.0.50727"构建的,如果没有其他配置信息,则无法在4.0运行时中加载.
类似的问题在这里:Visual Studio 2012测试项目混合模式运行时
我已将以下行添加到此文件夹中的所有.config文件:C:\ Program Files(x86)\ Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
Run Code Online (Sandbox Code Playgroud)
我甚至将它添加到此文件夹:C:\ Users\Alex\AppData\Local\Microsoft\VisualStudio\11.0\Extensions\zuclypws.1z3,其中包含xunit.runner.visualstudio.dll ..我将其命名为xunit.runner.visualstudio. dll.config
有谁知道如何使这个工作?我希望这不是那么复杂.
使用反序列化时,有没有办法获取$ type属性?我使用TypeNameHandling进行序列化,但是当我反序列化时,我没有包含类型信息的程序集。我需要使用Type名称将其存储在正确的集合中,看起来$ type不会被带到JObject中。
编辑:如果我反序列化为JObject,则可以获得$ type,但是如果我反序列化为以对象为属性的类,则该类型为null。不知道为什么json中会因为$ type而将其剥离。下面的例子:
班级
public class Container {
public object Test { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和反序列化代码
var container = new Container {
Test = new Snarfblat()
};
var json = JsonConvert.SerializeObject(container,
new JsonSerializerSettings {
TypeNameHandling = TypeNameHandling.Objects
});
var deserializedContainer = JsonConvert.DeserializeObject<Container>(json);
var type = ((JObject) deserializedContainer.Test)["$type"];
// Type is null
var deserializedContainer2 = JsonConvert.DeserializeObject<JObject>(json);
var type2 = deserializedContainer2["Test"]["$type"];
// Type is snarfblat
Run Code Online (Sandbox Code Playgroud) 在 Windows 调试器中,我试图打印出传递给 ac 函数的数据。我对传递给 System_Data_SQLite!sqlite3_step+0x63 的数据感兴趣。
0:071> kv 20
Child-SP RetAddr : Args to Child : Call Site
00000000`11b82e28 00000642`ff864776 : 00000000`12f6f450 00000000`0092dcd8 00000000`11b83488 00000000`11b83480 : ntdll!NtGetContextThread+0xa
00000000`11b82e30 00000000`12f6f450 : 00000000`0092dcd8 00000000`11b83488 00000000`11b83480 00000000`11b83470 : <Unloaded_mscordacwks.dll>+0x154776
00000000`11b82e38 00000000`0092dcd8 : 00000000`11b83488 00000000`11b83480 00000000`11b83470 00000000`77ee2ae9 : 0x12f6f450
00000000`11b82e40 00000000`11b83488 : 00000000`11b83480 00000000`11b83470 00000000`77ee2ae9 00000000`12c1a970 : 0x92dcd8
00000000`11b82e48 00000000`11b83480 : 00000000`11b83470 00000000`77ee2ae9 00000000`12c1a970 00000000`ffffffff : 0x11b83488
00000000`11b82e50 00000000`11b83470 : 00000000`77ee2ae9 00000000`12c1a970 00000000`ffffffff 00000000`00920be8 : 0x11b83480
00000000`11b82e58 00000000`77ee2ae9 : 00000000`12c1a970 00000000`ffffffff 00000000`00920be8 00000000`00000000 …Run Code Online (Sandbox Code Playgroud)