Tag: .net

错误:必须在顶级静态类中定义扩展方法(CS1109)

我正在尝试制作一个倒计时程序,我可以开始和停止,并在需要时将倒计时的值设置为10分钟。 但我收到的错误我不太明白。 我不是那样的C#,所以这里是代码: 有人可以帮我一点吗? 想想我在框架3.0上运行什么? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Timers; namespace PauseMaster { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { } private DateTime endTime; private void btnStartStop_Click(object sender, EventArgs e) […]

EF Core 1.1迁移 – 当前的CSharpHelper不能支持类型的文字

这似乎是一个非常模糊的错误,我甚至不知道从哪里开始…… 当前的CSharpHelper不能支持’System.Func`3 [Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator]’类型的文字。 配置您的服务以使用可以的服务。 这是在我跑的时候发生的 dotnet ef migrations add initial 更新1 – 基于Rob的问题 应用程序的体系结构使用了丰富的域模型,因此有一些“解决方法”可以获取封装集合等内容,而Jimmy Bogard的类型枚举模式也可以使用。 每个域模型对象在数据访问层中都有自己的EntityTypeBuilder类,所有这些都是从OnModelCreating中的DbContext 。 这些也会向Console输出一些信息,因此我可以看到构建器没有导致任何错误(此时都没有错误)。 DbContext仅为聚合根实体公开DbSet ,或者以另一种方式公开,只显示具有相应存储库类的实体。 其余的域模型对象是导航属性,因此不需要通过DbContext公开DbContext 。 平台细节(据我所知) .NET Core 1.1(运行时+ SDK) EF Core 1.1 Microsoft.EntityFrameworkCore.Tools 1.0.0-preview2-final Microsoft.EntityFrameworkCore.Design 1.0.0-preview2-final

从AD域获取所有用户

我需要能够识别我的AD(Active Directory)域中的所有用户。 我有域名,这是关于它。 如果我可以将它作为UserPrincipal的列表或其他东西,但如果它只是一个字符串然后我可以从那里获得我需要的其余信息,它会摇滚。 谢谢!

.net核心中的WCF(TransportWithMessageCredential)

当我尝试在dotnet core 2.0中创建与WCF客户端的连接时,我收到一个不支持的平台错误: System.PlatformNotSupportedException: ‘The value ‘TransportWithMessageCredential’ is not supported in this context for the binding security property ‘securityMode’.’ 如果我删除BasicHttpSecurityMode ,我收到一个参数exception:System.ArgumentException:’提供的URI方案’https’无效; 预计’http’。’ 码: ChannelFactory factory = null; BlackBoxContract serviceProxy = null; Binding binding = null; binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); factory = new ChannelFactory(binding, new EndpointAddress(“https:…….”));; serviceProxy = factory.CreateChannel(); 任何找到解决方法的人都可能在长期路线图中? https://github.com/dotnet/wcf/issues/8

ASP.NET加密 – aspnet_regiis – Farm

我们的网站使用“NT Authority \ Network Service”。 Response.Write(WindowsIdentity.GetCurrent().Name); 我们目前使用以下命令加密配置文件。 aspnet_regiis -pc “NetFrameworkConfigurationKey” aspnet_regiis -pa “NetFrameworkConfigurationKey” “NT Authority\Network Service” aspnet_regiis.exe -pef “connectionStrings” “C:\WebAppLocation\Folder” 注意:我们没有使用“-exp”。 当我们使用“-exp”时,它不会创建RSA密钥容器。 如您所见,我们使用默认密钥-NetFrameworkConfigurationKey。 我们的网站有一个负载均衡器。 Webserver1(W1)和WebServer2(W2)可用。 如果我按照上面提到的命令,我们将在W1和W2上使用单独的键。 然而,该网站使用这种方法。 这种方法是否足够? 是否有任何缺点或安全漏洞? 它会在任何情况下失败吗? 注意:我们的web.config中添加了机器密钥。 两个配置都是一样的。 但是,我们的configProtectedData不在Web.Config中。 另外,我认为,NetFrameworkConfigurationKey在两个服务器中都会有所不同。 我已经在Web场景方案中阅读了以下用于加密的msdn aricle。 http://msdn.microsoft.com/en-us/library/ff650304.aspx

Distinct()如何运作?

让我说我有这个: class Foo { public Guid id; public string description; } var list = new List(); list.Add(new Foo() { id = Guid.Empty, description = “empty” }); list.Add(new Foo() { id = Guid.Empty, description = “empty” }); list.Add(new Foo() { id = Guid.NewGuid(), description = “notempty” }); list.Add(new Foo() { id = Guid.NewGuid(), description = “notempty2” […]

如何在不使用.NET中的WMI的情况下找到硬盘设备序列号?

我想从硬盘上获取硬连线序列号但不使用WMI。 我尝试使用WMI代码,但它确实无法在我的机器上运行。 那么在.NET中是否有任何替代方法可以找到物理硬盘的序列号?

在不等待的情况下调用异步方法

我试图在不等待结果的情况下调用异步方法(在ASP.NET Web API 2应用程序中)。 我的意思是我想要主线程继续执行并且不等待被调用的方法来完成。 我正在尝试这个片段: // The async method: private static async Task LogAsync(Exception exception, string ip, MethodBase method, object parameters) { // some stuff } // The caller methods: public static void Log1(Exception exception, object parameters) { LogAsync(exception, ip, method, parameters); } public static void Log2(Exception exception, object parameters) { Task.Factory.StartNew(() => LogAsync(exception, […]

使用“mm”说明符格式化月份的DateTime ToString问题

我有一个问题,以获得正确的格式。 我期待“2013/10”,但我得到“2013/00”。 为什么会这样,我该如何解决这个问题呢? DateTime dt = DateTime.Parse(“2013-Oct-01”); string str2 = dt.ToString(“yyyy/mm”);

使用NHibernate的ISession.Get ()w /复合键

我在数据库表/ NHibernate实体中有一个复合键。 我可以以某种方式使用.Get方法来获取特定实体,还是因为复合键而必须使用HQL / Criteria?