RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-17974

nick_n_a's questions

Martin Hope
nick_n_a
Asked: 2022-03-01 22:55:04 +0000 UTC

如何阅读 orname LDAP

  • 0

我读到密码哈希存储在 msPKIAccountCredentials 中,当我尝试读取密钥时,我得到 __ComObject 无法转换成任何东西。AdExplorer 显示数据类型是“ORName”,数据似乎是“二进制”形式。如何使用 c# 读取此属性?这不是唯一具有这种“数据类型”的属性。

public static void Main(string[] args){
  System.DirectoryServices.DirectoryEntry d = new  System.DirectoryServices.DirectoryEntry("LDAP://мой_лдап.loc", "логин", "пароль");
  System.DirectoryServices.DirectorySearcher ds = 
  new System.DirectoryServices.DirectorySearcher(d, "(&(objectCategory=user)(mail=мой_емайл))");
   if (ds.FindOne() != null) {
   object x = ds.FindOne().GetDirectoryEntry().Properties["msPKIAccountCredentials"].Value;
   object[] xx = (object[])x;
   Type t = xx[0].GetType();
   Console.WriteLine(xx[0].ToString());
   // И всё.
  }
}

我收到了答案 __ComObject 并且不可能以任何方式减去值。这里似乎描述了“数据类型”或架构http://docs.microsoft.com/en-us/windows/win32/adschema/s-object-or-name 。

c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-01-27 21:33:18 +0000 UTC

DDR4 中的 CL 是什么?

  • 6

今天 RAM 的速度是多少?CL - CAS 延迟 - CAS 延迟......对于专业人士来说,它可能会说些什么。只是......为什么RAM的速度越高,CL就越高?我认为应该反过来。

我打开遇到的任何 ddr4,我没有找到数据表,例如,这里的 ddr3 http://www.icsi.com.tw/pdf/43TR16256A-85120AL.pdf我读到 - 13 纳秒 - 即 约 66MHz,即 内存本身是 1866MHz,但是 13 纳秒在这里做了什么?那些。未对齐的反转慢了 100 倍?对于 DDR4,它也变得难以理解 CL14 - 14 纳秒的延迟,即 66MHz 一样吗?尽管如此,他们承诺“带宽 19200 MB / s”的全速等于 8 * 2400 MHz。

  1. 我是否理解正确,cl14 的 cas 信号处理需要 14 ns,而 ras 小于纳秒?

  2. 事实证明,在一次 CAS 调用期间,可以进行 100 次 RAS 调用(大约 100,实际上是 1866/71Mnz = 26,但内存越高,指标越高)。如果我们故意强制处于保护模式的 CPU 对来自不同 CAS 页面的数据进行排序(您可以通过 cr3 将 256 个页面物理映射到 RAM,地址特别以 256MB 为间隔,并以 4096 的步长开始读取 1Gig 部分),那么我们会得到速度约70MHz(14ns)的内存吗?

  3. CL 参数会降低多少% 的内存性能?据我了解,页面大小... 32 位是 4Gb,配对的 RAS-CAS 提供大约 16 位。2 的 16 次方等于 64K,即超出 64Kbytes(可能真的是 256Kbytes)的内存边界,您必须切换页面。对于线性读取,每 64K 线性读取操作必须切换一次,每个 CAS 花费 ... 0.1K(对于 2400 CL14)。大约是0.1%吗?但在现实中,我们损失了 1% 到 10% 的 CL14 内存性能?2400/70МНz=34 循环 或者速度损失的百分比不同?

  4. 2400MHz CL14 和 2666MHz CL17 哪个更好?不知何故,数字 17 相当可怕。CL17(58MHz)会比n3慢1.2%到12%?2666/58=46 个周期。UDP:昂贵的DDR4 3200MHz CL15大约有55个空闲周期,看起来这个数字会增加......

память
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-01-21 16:32:02 +0000 UTC

华硕 LVDS 输出

  • 1

几年来,一直有40针LVDS输出的华硕主板,华硕prime H310T是最新款,也有老款H110T H81T。有没有人有任何机会?

在此处输入图像描述 从视觉上看,我想我们可以说从第 1 到第 8 条 LVDS 信号线,引脚 36、37、38 连接到左侧的连接器,带有三个位置的黄色开关 - 12v / 19v / 无电源。其余的......可能会打电话......

железо
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-08-06 19:26:07 +0000 UTC

如何请求提权?

  • 4

如何请求用户提升。例如,如果这是一个服务安装程序,则安装功能会出错 - 权限不足。许多安装程序将此作为常规启动对话框。那些。全屏窗口有两个字段:登录名和密码。我认为作为用户工作的每个人都知道这个窗口。如果工作从管理员(不是根)下进行,则窗口中有两个按钮 - 是和否。如何在 C# 中做到这一点?

c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-08-06 14:53:15 +0000 UTC

如何在一个 C# 中创建一个服务?

  • 0

如何在单个可执行文件中创建完整的服务?有一个现成的应用程序(你可以采取零winforms)。我添加了 services.cs,没有任何效果,没有例外。

ManagedInstallerClass.InstallHelper - 读取 - 失败。试图通过 RunInstaller 安装 - 也不起作用。

我尝试通过 sc create 安装(在命令行上) - 它已安装。

Services.cs 文本

using System;
using System.ServiceProcess;
using System.Configuration.Install;
using System.Collections;
using System.Collections.Specialized;
using System.Windows.Forms;


namespace CaiNiaoServiceWinForms{


class Service:ServiceBase  {

 static string  myname = "AMyService";

 public Service()
        {
            this.ServiceName = myname;
            this.CanStop = true;
            this.CanPauseAndContinue = false;
            this.AutoLog = true;
        }

  static public void Run() {
        ServiceBase[] ServicesToRun = new ServiceBase[] { new Service() };
        ServiceBase.Run(ServicesToRun);
     }

  protected override void OnStart(string[] args){ // TODO: add startup stuff
        }

        protected override void OnStop(){
           // TODO: add shutdown stuff
        }

//---------------------------------      
// Service config for UI          
// тут работает
  static ServiceController GetService() {
     foreach (ServiceController item in  ServiceController.GetServices())
            if (item.ServiceName == myname) return item;
     return null;
     }


  public static bool Installed {
        get { // тут работает
          return (GetService()!=null);
          }

        set { // тут не работает
           string  servicePath = System.Reflection.Assembly.GetEntryAssembly().Location;
           if (value) { /*install*/
MyInstaller inst = new MyInstaller();
//inst.Install(dict); не работает, даже если создать словарь
//inst.Commit(dict);
              } 
              //ManagedInstallerClass.InstallHelper(new[] { "/i" , servicePath, "/SERVICE" });

              //ManagedInstallerClass.InstallHelper(new[] { servicePath , "/SERVICE" });
             }  else { /*uninstall*/
              ManagedInstallerClass.InstallHelper(new[] { "/u" , servicePath, "/SERVICE" });
             }


            }
      }


  public static void DoStart () {
      if (Installed) GetService().Start();
      }


  public static void DoStop () {
      if (Installed) GetService().Stop();
      }




  }
//------------------

  [System.ComponentModel.RunInstaller(true)]
  public partial class MyInstaller: Installer { 
    // https://docs.microsoft.com/ru-ru/dotnet/api/system.serviceprocess.serviceinstaller
    private ServiceInstaller serviceInstaller;
    private ServiceProcessInstaller processInstaller;     


      public MyInstaller() {
         processInstaller = new ServiceProcessInstaller();
         serviceInstaller = new ServiceInstaller();
         processInstaller.Account = ServiceAccount.LocalSystem;
         serviceInstaller.StartType = ServiceStartMode.Manual;
         serviceInstaller.Context  = 
            new System.Configuration.Install.InstallContext(null, new string[]{"/SERVICE"});
         }

      }           
}

我的主要(program.cs)

static void Main(string[] args)
{
   try {

    if (args.Length > 0) {
      if (args[0]  == "/SERVICE") {
            Service.Run();
            return;
            }

      if (args[0].ToUpper()  == "/INSTALL") { 
          Service.Installed = true; 
          return;
          }
      if (args[0].ToUpper()  == "/UNINSTALL") {
          Service.Installed = false;
          return;
          }
      }
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new MainForm(args));
    } catch (Exception e) {
      MessageBox.Show(e.ToString());
      }
}
c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-01-16 23:04:39 +0000 UTC

如何在richedit中关闭声音

  • 2

如果,当光标位于位置 0,0 时,您按向左或向上(即尝试离开可编辑区域),则标准 Richedit 会发出声音信号(可能是响铃)。如何消除这种蜂鸣声?

我正在使用 CreateWindowEx,这是一个创建richedit http://docs.microsoft.com/en-us/windows/desktop/controls/create-rich-edit-controls的示例,如下所示:

 LoadLibrary(TEXT("Msftedit.dll"));

 HWND hwndEdit= CreateWindowEx(0, MSFTEDIT_CLASS, TEXT("Type here"),
    ES_MULTILINE | WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP, 
    x, y, width, height, 
    hwndOwner, NULL, hinst, NULL);

PS 在 Windows 中,有一个“明亮”的 Richedit 使用不佳的例子 - 写字板。开发人员没有打扰 - 他们留下了声音(或者可能是有意的)。运行写字板向左按 - 会有同样的尖叫声。

如果有Delphi的例子,对于СRichEdit组件等,它使用WINAPI的richedit组件,那么它也是合适的,我已经找到并挖掘如何在WINAPI中做到这一点。

c++
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-01-03 18:39:45 +0000 UTC

c#和调试模式

  • 3

是否可以在“跟踪”模式下运行 C# CLR 代码?有什么方法可以拦截 Invoke 调用吗?如何为 c# 代码编写调试器?目前唯一想到的就是模拟CLR代码的执行,但是这里需要模拟器上一大堆代码,然后……截取现成库的代码,因为有CLR- Native-CLR 桥接,所以模拟器没那么简单。我с++-cli认为实现这个奇迹是现实的……但是……我认为有某种特殊的模式可以很容易地开启。看到已经有 VS 的“弯曲”类似物......如何在其他项目中解决这个问题?

c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-12-26 20:31:02 +0000 UTC

MSSQL Rest API 查询

  • 3

是否可以通过MSSQL对给出表格的url进行请求,以表格的形式显示出来?

declare @xmlhttp int
declare @hr int
declare @text char(8000)
exec sp_OACreate 'Msxml2.XMLHTTP', @xmlhttp out
exec @hr=sp_OAMethod @xmlhttp, 'open', NULL, 'GET', 
      'http://10.0.0.0:8080/API/flat?token=c57aa1', false
if @hr=0  exec @hr = sp_OAMethod @xmlhttp,
  'setRequestHeader', null, 'Content-Type', 'text/html'
if @hr=0 exec @hr = sp_OAMethod @xmlhttp, 'send', NULL, null
-- тут hr равен нолю - без ошибок
if @hr=0 exec @hr = sp_OAGetProperty @xmlhttp, 
'responseText',  @text out;
--- тут возникают ошибки "конвертации"

当responseText超过 8000 个字符时出现问题 - 然后无法读取它(MSSQL 对字符串大小的限制)。如果其他方式从另一台服务器获取 json 表并在 MSSQL 中处理?

UPD:而且......就像......不可能将文本转换为表格(之前我通过xml编写了一个变态,它通过xml工作)。写作...

SELECT 
cast((select value from OPENJSON(value) 
  where [key]='id') as int) id,
cast((select value from OPENJSON(value) 
  where [key]='name') as varchar(32)) name
FROM OPENJSON( (select x from @tab)  )

看起来没问题,我把它放在存储中并执行一个 exec 然后......

消息 208,级别 16,状态 1,过程 update_rest2,第 32 行 [批处理开始第 2 行] 对象名称“OPENJSON”无效。

json视图[{"id":18120,"name":"Smart"},{"id":18124,"name":"Smart4"}]

有没有人遇到过这样的笑话?不能在存储中工作,但在没有存储的情况下工作(服务器 2016)

sql-server
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-07-02 15:10:46 +0000 UTC

如何设置程序断点

  • 3

如何在不同的语言、环境和 IDE 中放置程序断点。经常看到问题,不能调试程序,因为程序很大,体积很大。Loop on 10000000。这样的情况可以被捕获,比如发生错误的时候,我有i = 357489,并且不清楚为什么会发生异常,那么我们这样做,比如这样:

 for (i=0;i<10000000;i++) {
   if (i==357489) DebugBreak();
   // код
   }

但是DebugBreak- windows 的功能。其他环境如何设置断点?

отладка
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-06-25 21:14:22 +0000 UTC

c# 中有 preg_replace 的类似物吗?

  • 1

有一个“模板词”数组。从数据库中读取模式(模式)后,是否有可能将“模板词”自动替换为必要的词。例如

“您好 %client%。您的订单 %order% 将于 %date% 交付”。

好吧,Dictionary<string,string>例如,如果有一个数组,或者如果有两个数组 - 替换什么,替换什么。那些。内置模板引擎。

或者……至少……通过正则表达式来做,或者有一个更短的解决方案。

c#
  • 5 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-05-18 17:41:52 +0000 UTC

拼写检查器库

  • 4

c++ 中是否有用于 Windows 的拼写检查库(只是单词的拼写)?

对于 Richedit,我发现EM_SETLANGOPTIONSIMF_SPELLCHECKING仅在 windows-8中启用拼写检查。并且没有“检查这个词”的功能。

在 windows-xp 中,我的 Firefox 将文本排成红色。

winxp 的操作系统中是否内置了拼写检查功能?

win7的操作系统是否内置了拼写检查?

什么是最简单的拼写检查库?我对“检查这个词”功能感兴趣,但也许还有其他概念。Edit 或 Richedit 的“附加组件”也是合适的。

c++
  • 2 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-05-14 14:09:38 +0000 UTC

音频编解码器是否有硬件支持?

  • 2

是否有音频编解码器的硬件支持。如果有,有哪些?可以使用哪些库来获得硬件加速?

我阅读了 USB 标准,USB 音频标准包括对编解码器的支持,包括 mp3,但 USB 声卡还没有那么普遍。

  • 现代显卡是否支持 mp3 和 AAC,或者您是否使用软件编解码器(例如 Realtek HD Audio)?
  • 声卡支持哪些编解码器?
  • 哪些 c++ 库支持通过硬件压缩播放?
  • 声卡可以同时编码多少个音频流?

还是声卡厂商不理会编解码器,只有部分USB声卡支持mp3?

c++
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-04-19 22:23:25 +0000 UTC

速度更快的 MSSQL。通用设计的优化

  • 1

我经常对 mssql 中哪种方式更快有疑问。

  1. where @id is null or id = @id或where isnull(@id,id)=id 问题出现是因为 mssql 中的 or 操作通常较慢。

  2. where id = 1 or id = 2或where id in (1,2)类似的。

我想在这个问题中收集更多有争议的解决方案,让您更好地优化sql代码。

sql-server
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-03-02 17:26:53 +0000 UTC

如何取出视图参数?

  • 0

是否可以取出视图参数使其不会创建函数?

我需要选择“历史”,即 类型选择:

select * from filials p
  left join filials rea on rea.number = p.number 
  and (@date between         rea.dateopen and '12.12.9999')
where @date between p.datestart and p.datestop 

那些。示例中的参数@date2 次(我有 10 次)分别用一个线程渗透到整个请求中,这仍然不是一个函数,而是一个选择。是@date 阻止你简单地输入它create view as select。是否可以以某种方式或在其中放置一个参数......是否可以使这个选择完全成为一个视图而不是一个函数?(有人猜测该功能会降低性能)。

我需要一个视图,即 create view myview1 as ....和@date 参数“干扰”

sql
  • 2 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-12-26 21:50:23 +0000 UTC

__line__ 代码行号

  • 17

不是我第一次写

log1(613,"msg");
log1(614,"msg");

__LINE__c++在www.cprogramming.com 和c++ logging function中有一个很酷的东西 ,是否有一个简单的解决方案可以让 c# 准确记录正在执行的行?

c#
  • 2 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-12-18 16:28:07 +0000 UTC

如何计算html元素的坐标

  • 4

如何计算(获取)一个 html 元素的位置。offsetTop并offsetLeft给出一个相对值(并不总是来自[x=0,y=0]原点的报告)。谷歌给出了一个“未完成”的版本http://javascript.ru/ui/offset。

不是“如何在滚动过程中动态确定元素相对于其父元素的当前位置”,而是如何获取相对于页面内容左上角的绝对坐标。

第二个问题又是“确定一个元素相对于其父元素的当前位置”,相对于页面内容左上角的绝对坐标。

有必要将元素“悬挂”到当前布局(以便在某个元素上/附近显示提示、消息、广告等),如下所示:

      document.getElementById("act_holder").style.position= "absolute";
      document.getElementById("act_holder").style.display = "block";
      document.getElementById("act_holder").style.top = 
          (getOffset(document.getElementById("act_hlp")).top - 75 ) + "px";    
      document.getElementById("act_holder").innerHTML = "элемент занят"; 

使用时absolute,需要相对于左上角的坐标。

javascript
  • 3 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-10-30 23:50:03 +0000 UTC

MVC 模型,如何在所有模型(或整个程序)中“拖动”一个属性?

  • 0

ef + mvc上有一个项目。用漂亮的控制器 + 30 个模型 + n-view 它需要在所有页面(视图)上写下公司的名称。事实证明......您需要对所有模型进行更改,而不仅仅是更改,还要将它们与存储库(IRepository)相关联,因为公司的名称存储在IQueryable<Company> companies存储库-DBMS中(一些模型是链接的,有些不是)?没有更简单的方法吗?一切都应该通过全球模式来完成……还是有针对这种情况的“全球”机制?也许这不应该通过模型来完成......

现在更详细。数据库通过 EF 连接,它通过构造函数连接到控制器,例如

public class HomeController : BaseController
{
    private IProductRepository _repository;
    public HomeController(IProductRepository productRepository)
    {
        this._repository = productRepository;
    }
}

视图的一部分连接到存储库的单独表IQueryable。在主(主页)页面上,选择了一家公司。我是这样实现的:

    @model MyProj.WebUI.Models.ProductsListViewModel
    @{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    }
    ...
   @foreach(var item in Model.Companies){     
         <h1 style="font-family:'Lobster';color:white">
             <a style="font-size:x-large;color:blue;" href="/Menu?c=@item.Id">@item.Name</a>
         </h1>     
   }

由于用户可以选择任何公司,所以我没有加密 id 或将其设置为 post-request(这不是那么重要,它无论如何都会落入 Request 中)。

我给自己定了一个任务。我在主页上有一个菜单。选择“公司”后,我需要在其他页面上显示其名称。我会将公司名称存储在Request["c"]. 接下来,稍微介绍一下解决方案。我会检查模型是否支持 Companies 属性,如果支持,我会保存公司的名称和 id,然后我会从“缓存”中显示它们。最有可能通过 ViewBag。

我不知道是否有可能以“一般”的方式解决这个问题。我已经为自己“概述”了一个解决方案,稍后我会发布它。我认为其他人也会面临类似的问题。

c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-10-27 20:17:51 +0000 UTC

为什么模型没有被传递给视图?

  • 0

有一个页面

@model MyProj.WebUI.Models.ProductsListViewModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<span>@this.Model.ToString();</span> // 6

最后一行抛出异常

[NullReferenceException:对象引用未设置为对象的实例。] c:\inetpub\wwwroot\Views\Home\Index.cshtml:6
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 中的 ASP._Page_Views_Home_Index_cshtml.Execute() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +146
System.Web.WebPages.StartPage.ExecutePageHierarchy() +88
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +106
System .Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext 上下文)+374

我家的控制器是这样的

public class HomeController : BaseController{
        private IProductRepository _repository;
        public HomeController(IProductRepository productRepository)
        {
            this._repository = productRepository;
        }

        [CustomAuthorize]
        public ActionResult Index()
        {
            return View();
        }

    }
}

Controller-Model 绑定写在哪里?

c#
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-10-26 23:12:28 +0000 UTC

EF GetDbProviderManifestToken MySql 迁移报错,如何取胜?

  • 0

我在 NuGet 控制台中执行 PM>Enable-Migrations -Force

我捕捉到文本检查上下文是否针对现有数据库...然后是异常

System.NullReferenceException:对象引用未指向对象的实例。到 MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection 连接) 到 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection 连接) 到 MySql.Data.Entity.MySqlManifestTokenResolver.ResolveManifestToken(DbConnection 连接) 到 System.Data .Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) 到 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) 到 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) 到 System.Data。 Entity.Internal.RetryLazy 2.GetValue(TInput 输入) 到 System.Data.Entity.Internal.LazyInternalContext。
在 System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized() 在 System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer) 在 System.Data.Entity.Utilities.DbContextExtensions.<>c__DisplayClass1.b__0( XmlWriter w) 到 System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml) 到 System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context) 到 System.Data.Entity.Migrations.DbMigrator..ctor System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration 配置) 中 System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration) 到 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() 到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 到 System.Data.Entity。 Migrations.Design.ToolingFacade.Run(BaseRunner runner) 到 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(String language, String rootNamespace) 到 System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 中的 >b__0() 对象引用不指向对象的实例。DoCallBack(CrossAppDomainDelegate callBackDelegate)到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)到 System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)到 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(字符串语言, String rootNamespace) in System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 对象引用不指向实例的一个对象。DoCallBack(CrossAppDomainDelegate callBackDelegate)到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)到 System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)到 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(字符串语言, String rootNamespace) in System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 对象引用不指向实例的一个对象。String rootNamespace) in System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 对象引用不指向实例的一个对象。String rootNamespace) in System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 对象引用不指向实例的一个对象。

尝试删除迁移文件夹 - 没有帮助。有旧的迁移,但由于某种原因,NuGet 控制台看不到它们。最有可能的是,迁移已经确定,它将有关项目的数据保存在某个地方。

版本 MySql 基础

EFv6.0

VS 2017

如何恢复迁移?还是 EF-MySql 库本身的问题?

mysql
  • 1 个回答
  • 10 Views
Martin Hope
nick_n_a
Asked: 2020-10-26 14:49:16 +0000 UTC

如何在 EF 中添加表?

  • 0

有一个项目,需要将表添加到其中。一切都会好起来的,只是在我做 drop database 之后,表没有出现在数据库中,好吧,我可以理解得到一个异常。(我补充说是的,当我启动项目时表没有出现,我认为删除 DBMS 会强制创建它,为此我删除了 subd)MySQL 基础。现在了解更多详细信息...在 Entities\DataBase 文件夹中添加了一个表

namespace MyProj.Domain.Entities.Database{
  public class Company{
    [Key]
    public int Id { get; set; }

    [MaxLength(255)]
    public String Name { get; set; }
}}

继续前行。文档说要查看 Entities\Migrations\Configuration.cs,我看...

internal sealed class Configuration : DbMigrationsConfiguration<MyProj.Domain.Concrete.MysqlEfDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
        CodeGenerator = new MyCodeGenerator();
    }

我走进MysqlEfDbContext

[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class MysqlEfDbContext : DbContext
{
   public DbSet<Company> Companies { get; set; } // Дописал сюда таблицу, 
   // тут аналогично находятся другие таблицы
   public DbSet<User> Users { get; set; }
}

是的,该类MyCodeGenerator- 不包含对表的引用。没发布,没看到有什么特别的,方法Generate和调用的拦截。StripDbo

在更改之前 - 数据库、表已创建并且一切正常。更改后,创建了一个没有新表的数据库,并且出现了异常

无法更新数据库以匹配当前模型,因为存在待处理的更改并且自动迁移已禁用。将挂起的模型更改写入基于代码的迁移或启用自动迁移。将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。

好吧,既然他们写true了——顺其自然,我们就说吧 AutomaticMigrationsEnabled = true;。然后我得到另一个错误

表 'concreteperiods' 已经存在。

(这是要创建的第一个表的名称)。公司表现已创建。第一个和第二个错误都出现在这里:

var user = (_repository.Users != null)?_repository.Users.
   ToList().FirstOrDefault(x => x.Username.Equals(model.UserName) 
 && x.Password.Equals(model.Password)) : null;

我看看是什么_repository

namespace MyProj.WebUI.Controllers
{
public class AccountController : Controller
{
    private IProductRepository _repository;
    readonly IAuthProvider _authProvider;
    public AccountController(IAuthProvider auth, IProductRepository repo)
    {
        _repository = repo;
        _authProvider = auth;
    }

没有AccountController链接。

阅读有关迁移的信息。现在是移民的故事。
在控制台启用迁移。Studio zero - 出现错误 - 我不知道命令。在项目上制作鼠标右键-> 恢复包。启用迁移

PM> Enable-Migrations
Code First Migrations enabled for project MyProj.Domain.
PM> Add-Migration "company"
The project 'MyProj.Domain' failed to build.

我查看了项目 - 我在根目录中创建了另一个 Migrations 文件夹,其中还有另一个 Configuration.cs 文件 - 结果 - 项目不会,因为 Configuration 类被声明了两次。删除,重复添加迁移“公司”我得到一个错误更有趣......

PM> Add-Migration "company" System.NullReferenceException:对象引用未指向对象的实例。在 MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection 连接) 在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection 连接) 在 MySql.Data.Entity.MySqlManifestTokenResolver.ResolveManifestToken(DbConnection 连接) 在 ... System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() 到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 到 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 到 System.Data.Entity.Migrations.Design.ToolingFacade。在 System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold 运行(BaseRunner runner)(字符串迁移名称,字符串语言,

EntityFramework 版本 6.0.0.0,运行时 v 4.0.30319

VS 2017

您还能看到什么,是否有需要在“第一次启动”时创建的表列表?

c#
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5