我正在使用IISExpress8运行Windows Server 2008 R2(x64)并导航到
c:\Program Files (x86)\IIS Express>iisexpress.exe
Run Code Online (Sandbox Code Playgroud)
它说:
文件名:redirection.config
错误:无法读取配置文件
任何想法从哪里开始?我找不到任何东西......
如何从IMethodSymbol(Roslyn语法树)可靠地获取MethodInfo(反射).我可以从IMethodSymbol获取Type,并且该类型有许多方法,其中一个方法与IMethodSymbol实例匹配.
例如
int i = 0;
i.Equals(5);
Run Code Online (Sandbox Code Playgroud)
IMethodSymbol识别'等于'的地方
注意,[Int32]类型有2个[Equals]方法,一个采用[Object],另一个采用[Int32]参数.
我正在解析脚本,我没有任何工作区实例.
有任何想法吗?斯特沃
有一个有趣的问题 - 我需要将2个(随机)生成的Guid转换为字符串.以下是约束:
到目前为止,我已经浏览了很多寻找到底池36的转换,但是Guid没有运气.
有任何想法吗?(C#)
我正在Azure上运行Service Bus,每秒大约需要10-100条消息.
最近我转而使用.net 4.5并且所有兴奋重构的所有代码都在每行中至少有两次'async'和'await ',以确保它'正确'完成':)
现在我想知道它实际上是好还是坏.如果你能看一下代码片段,请告诉我你的想法.我特别担心,如果线程上下文切换没有给我带来更多的悲伤而不是从所有的异步中获益......(看看!dumpheap肯定是一个因素)
只是一些描述 - 我将发布2个方法 - 一个在ConcurrentQueue上执行while循环,等待新消息和另一个一次发送一个消息的方法.我也正在使用Transient Fault Handling块,正如Azure博士所规定的那样.
发送循环(从头开始,等待新消息):
private async void SendingLoop()
{
try
{
await this.RecreateMessageFactory();
this.loopSemaphore.Reset();
Buffer<SendMessage> message = null;
while (true)
{
if (this.cancel.Token.IsCancellationRequested)
{
break;
}
this.semaphore.WaitOne();
if (this.cancel.Token.IsCancellationRequested)
{
break;
}
while (this.queue.TryDequeue(out message))
{
try
{
using (message)
{
//only take send the latest message
if (!this.queue.IsEmpty)
{
this.Log.Debug("Skipping qeued message, Topic: " + message.Value.Topic);
continue;
} …
Run Code Online (Sandbox Code Playgroud) 我一直在慢慢耗尽内存。我已经使用 WinDbg 来查看内存转储,这是它的样子:
000007f975ee0630 557377 41027736 System.Object[]
000007f975f004d0 18781 47746604 System.Byte[]
000007f975efc358 561433 54013658 System.String
000000000137b170 7616 1322123700 Free
Total 7627101 objects
Fragmented blocks larger than 0.5 MB:
Addr Size Followed by
000000004a9f62b0 18.2MB 000000004bc28050 System.Threading.OverlappedData
000000004dc2ce68 16.1MB 000000004ec522e8 System.Threading.OverlappedData
0000000050adaec0 10.3MB 0000000051525620 System.Threading.OverlappedData
000000005d47fd98 10.2MB 000000005deab618 System.Threading.OverlappedData
0000000071718ab8 23.0MB 0000000072e13a80 System.Threading.OverlappedData
0000000072e13e50 11.8MB 00000000739e4898 System.ServiceModel.Channels.SocketConnection
00000000801a7830 29.7MB 0000000081f5dd60 System.Threading.OverlappedData
000000008264ab58 14.0MB 000000008344bac0 System.Threading.OverlappedData
000000008344bb30 11.6MB 0000000083fecf80 System.Threading.OverlappedData
0000000083fecff0 13.6MB 0000000084d8dae8 System.Threading.OverlappedData
0000000084d8db58 148.3MB 000000008e1d65f8 System.Threading.OverlappedData
0000000093db04e0 19.4MB 00000000951158b8 System.Threading.OverlappedData …
Run Code Online (Sandbox Code Playgroud) .net memory-leaks asynchronous memory-fragmentation .net-4.5
这行(C#)代码
if (!currentLap.S1.HasValue)
Run Code Online (Sandbox Code Playgroud)
给了我
System.NullReferenceException:未将对象引用设置为对象的实例.
如果我确定currentLap变量被实例化(因为它之前使用了几行而且它是一个局部变量)并且它具有以下属性:
private double? _s1;
[DefaultValue(null)]
[JsonConverter(typeof(ShortDoubleConverter))]
public double? S1
{
get { return _s1; }
set { _s1 = value; }
}
Run Code Online (Sandbox Code Playgroud)
怎么可能抛出NullReferenceException?它可以与发布模式下的优化有关吗?
谢谢,Stevo
编辑:
这是完整的方法代码.
public void Update(DriverData driverData)
{
LapInfo currentLap = this.CurrentLap;
if (currentLap != null &&
this.LastDriverData != null &&
driverData.TotalLaps != this.LastDriverData.TotalLaps &&
driverData.InPits &&
driverData.Speed < 10 &&
!this.LastDriverData.InPits)
{
currentLap.Escaped = true;
}
this.LastDriverData = driverData;
if ((currentLap == null || currentLap.Lap != driverData.LapNumber) &&
!this.Laps.TryGetValue(driverData.LapNumber, out currentLap)) …
Run Code Online (Sandbox Code Playgroud) 我有一个从数据库生成的实体框架模型.其中一个实体是'Session'和'Type'int属性.
自动生成的课程:
public class Session
{
int Type { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
EDMX:
<EntityType Name="Sessions">
<Property Name="Type" Type="int" Nullable="false" />
</EntityType>
Run Code Online (Sandbox Code Playgroud)
有时在加载数据库值时,我得到一个异常,说它不能将'Type'属性(这是int)设置为'string'值:
System.InvalidOperationException:'Session'上的'Type'属性无法设置为'System.String'值.您必须将此属性设置为类型为"System.Int32"的非null值.位于System.Data.Entity.Core.Common.Internal.Materialization.Coordinator的
1.GetValue(DbDataReader reader, Int32 ordinal) at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName) at lambda_method(Closure , Shaper ) at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func
lambda_method(Closure,Shaper)的System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader 2 constructEntityDelegate,EntityKey entityKey,EntitySet entitySet)1.ReadNextElement(Shaper shaper) at System.Data.Entity.Core.Common.Internal.Materialization.Shaper
1.SimpleEnumerator.MoveNext()在System.Linq.Enumerable.FirstOrDefault [TSource](IEnumerable的1 source) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable
1个源)
这是失败的查询:
var session = db.Sessions.Include("Game.Mod").Where(s => s.UniqueId == message.SessionUid && s.DomainId == this.DomainId && s.Game.UniqueId == message.GameUid).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
在本地调试时,一切正常.这是在部署到prod时.
我目前在sql azure上使用EF 6.1,我认为它可能与升级有关,我不认为这发生在之前(使用6.1).但我可能错了.
数据库列也是一个int(100%确认),映射是正确的.
我们正在使用通过 http 序列化为 JSON 的大型 (GB) 网络流,使用 Newtonsoft.Json nuget 包将响应流反序列化为内存中记录以进行进一步操作。
鉴于数据量过多,我们使用流式传输一次接收一大块响应,并希望在达到 CPU 限制时优化此过程。
优化的候选者之一似乎是JsonTextReader,它不断分配新对象,从而触发垃圾收集。
我们遵循 Newtonsoft Performance Tips的建议。
我创建了一个示例 .net 控制台应用程序,模拟当 JsonTextReader 读取响应流时分配新对象的行为,分配表示属性名称和值的字符串
问题:我们是否还可以调整/覆盖其他内容以重用已分配的属性名称/值实例,因为在现实世界中,其中 95% 是重复的(在测试中是相同的记录,因此 100% 重复)?
示例应用程序:
Install-Package Newtonsoft.Json -Version 12.0.2
Install-Package System.Buffers -Version 4.5.0
Run Code Online (Sandbox Code Playgroud)
程序.cs
using System;
using System.Buffers;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace JsonNetTester
{
class Program
{
static void Main(string[] args)
{
using (var sr = new MockedStreamReader())
using (var jtr = new JsonTextReader(sr))
{
// does not …
Run Code Online (Sandbox Code Playgroud) .net ×5
c# ×5
asynchronous ×2
.net-4.5 ×1
base36 ×1
guid ×1
iis-express ×1
json.net ×1
memory-leaks ×1
methodinfo ×1
nullable ×1
performance ×1
reflection ×1
release ×1
roslyn ×1
servicebus ×1