小编Dar*_*rse的帖子

如何找到"访问冲突"的来源

简而言之,我有一个C#应用程序执行大量mciSendString调用(通过dllimport)来控制wav文件播放(基本上是打开,播放,暂停,停止,状态,关闭).运行一段时间后,应用程序崩溃,恕不另行通知"访问冲突".

即使我从我的vs2012运行应用程序,视觉工作室也没有抓住异常.即使有'强行突破异常'选项,我也没有运气从vs2012调试这个.所以我设置WER来生成崩溃转储,我使用windbg和psscor2.dll插件来调试它.

然后按顺序,使用以下命令,这是我得到的(为了可读性而缩短为必要的):

$>.ecxr

eax=00000001 ebx=00000000 ecx=00000401 edx=00000000 esi=049725b8 edi=00000002
eip=4e88159e esp=0a4efa38 ebp=0a4efa54 iopl=0         nv up ei pl nz ac pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010216
<Unloaded_mciwave.dll>+0x159e:
4e88159e ??              ???
Run Code Online (Sandbox Code Playgroud)

$>〜*KB

#  19  Id: 105c.28cc Suspend: 1 Teb: 7ef06000 

Unfrozen
user32!NtUserGetMessage+0x15
user32!GetMessageA+0xa1
winmm!mciwindow+0x102
kernel32!BaseThreadInitThunk+0xe
ntdll!__RtlUserThreadStart+0x70
ntdll!_RtlUserThreadStart+0x1b

# 30  Id: 105c.15f8 Suspend: 0 Teb: 7ef1b000 Unfrozen
ntdll!ZwWaitForMultipleObjects+0x15
KERNELBASE!WaitForMultipleObjectsEx+0x100
kernel32!WaitForMultipleObjectsExImplementation+0xe0
kernel32!WaitForMultipleObjects+0x18
kernel32!WerpReportFaultInternal+0x186
kernel32!WerpReportFault+0x70
kernel32!BasepReportFault+0x20
kernel32!UnhandledExceptionFilter+0x1af
ntdll!__RtlUserThreadStart+0x62
ntdll!_EH4_CallFilterFunc+0x12
ntdll!_except_handler4+0x8e
ntdll!ExecuteHandler2+0x26
ntdll!ExecuteHandler+0x24
ntdll!RtlDispatchException+0x127
ntdll!KiUserExceptionDispatcher+0xf
WARNING: Frame IP not in any known …
Run Code Online (Sandbox Code Playgroud)

windbg winmm access-violation mci windows-error-reporting

6
推荐指数
1
解决办法
7767
查看次数

动态查找DbContext中的通用DbSet

我知道这个问题已被提出,但我找不到让我满意的答案.我想要做的是DbSet<T>根据类型的名称检索一个特定的.

我有以下内容:

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyDllAssemblyName")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyCallingAssemblyName")]

class MyDbContext : DbContext {

    public DbSet<ModelA> A { get; set; }
    public DbSet<ModelB> B { get; set; }

    public dynamic GetByName_SwitchTest(string name) {
        switch (name) {
            case "A": return A;
            case "B": return B;
        }
    }

    public dynamic GetByName_ReflectionTest(string fullname)
    {
        Type targetType = Type.GetType(fullname);
        var model = GetType()
            .GetRuntimeProperties()
            .Where(o => 
                o.PropertyType.IsGenericType &&
                o.PropertyType.GetGenericTypeDefinition() == typeof(DbSet<>) &&
                o.PropertyType.GenericTypeArguments.Contains(targetType))
            .FirstOrDefault();
        if (null != model)
            return model.GetValue(this);
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

无论是通过简单的开关还是反射,我都可以轻松获取类型.然而,我需要将类型作为动态返回,因为我不知道它将是什么类型的DbSet.然后在同一个程序集中的其他地方,我这样使用它: …

.net c# asp.net-mvc-5 entity-framework-core

5
推荐指数
1
解决办法
7520
查看次数

在visual studio 2015下以x86开始一个asp.net核心项目

我有一个包含asp.net核心项目的vs2015解决方案,并将其project.json配置如下:

{
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "platform": "x86"
  },
  "runtimes": {
    "win10-x86": {}
  },
  "frameworks": {
    "net461": {}
  },
  "commands": {
    "web": "Microsoft.AspNet.Hosting --ASPNET_ENV production --server Microsoft.AspNet.Server.Kestrel --server.urls http://+:12345",
  }
  [...]
}
Run Code Online (Sandbox Code Playgroud)

我期待应用程序使用project.json中指定的平台构建和运行(仅供参考,我在win10/x64框上通过vs2015调试器运行应用程序).但是,使用win7-x64运行时代替.我可以看到一个win7-x64输出目录,启动的提示标题也表明它.

如果我通过指定运行时的命令行直接构建和运行,它就可以工作.

所以我的问题是,我还需要配置什么来从vs2015启动x86中的asp.net核心应用程序?

c# visual-studio-2015 asp.net-core

4
推荐指数
2
解决办法
1767
查看次数