我创建了一个新的 AWS Lambda .NET Core 3.1 项目,然后使用 AWS Lambda 测试工具运行它,然后我按预期得到了这个页面:
但是,如果我安装这些软件包之一:
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.Data.SqlClient
当我运行时,出现此错误并且无法打开测试页面:
AWS .NET Core 3.1 Mock Lambda Test Tool (0.10.0)
Unknown error occurred causing process exit: Dependency resolution failed for component C:\Users\siri\repos\bolao-futebol\website-core\AWSLambda1\bin\Debug\netcoreapp3.1\AWSLambda1.dll with error code -2147450740. Detailed error: Error:
An assembly specified in the application dependencies manifest (AWSLambda1.deps.json) was not found:
package: 'runtime.win-x64.runtime.native.System.Data.SqlClient.sni', version: '4.4.0'
path: 'runtimes/win-x64/native/sni.dll'
at System.Runtime.Loader.AssemblyDependencyResolver..ctor(String componentAssemblyPath)
at Amazon.Lambda.TestTool.Runtime.LambdaAssemblyLoadContext..ctor(String lambdaPath) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LambdaAssemblyLoadContext.cs:line 28
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory, IAWSService awsService) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 71
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory) …
Run Code Online (Sandbox Code Playgroud) 如何检测用户何时在Windows 7中锁定/解锁屏幕?
我发现这个问题有一个C#的答案,但我想在Delphi 2009中使用它.我猜有一些Windows消息(像这些)可以完成这项工作.这是我试过的代码,但它不起作用:
const
NOTIFY_FOR_ALL_SESSIONS = 1;
{$EXTERNALSYM NOTIFY_FOR_ALL_SESSIONS}
NOTIFY_FOR_THIS_SESSION = 0;
{$EXTERNALSYM NOTIFY_FOR_THIS_SESSION}
type
TfrmAlisson = class(TForm)
lbl2: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
public
FLockedCount: Integer;
procedure WndProc(var Message: TMessage); override;
function WTSRegisterSessionNotification(hWnd: HWND; dwFlags: DWORD): bool; stdcall;
function WTSUnRegisterSessionNotification(hWND: HWND): bool; stdcall;
end;
implementation
uses
// my impl uses here
procedure TfrmAlisson.FormCreate(Sender: TObject);
begin
if (WTSRegisterSessionNotification(Handle, NOTIFY_FOR_THIS_SESSION)) then
ShowMessage('Nice')
else
begin
lastError := GetLastError;
ShowMessage(SysErrorMessage(lastError));
end;
end;
procedure TfrmAlisson.FormDestroy(Sender: TObject);
begin …
Run Code Online (Sandbox Code Playgroud) 我正在为Angular 5项目使用Angular Material.我想将工具栏标题与中心对齐.
在他们的文档中,他们提到:
工具栏不会对其内容执行任何定位.这使用户有足够的能力来定位符合其应用的内容.
一种常见的模式是在左侧放置标题,在右侧放置一些操作.这可以通过display:flex来轻松完成:
这是我试过的:
<mat-toolbar color="primary">
<span class="title-center">TITLE</span>
</mat-toolbar>
.title-center {
flex: 1 1 auto;
}
Run Code Online (Sandbox Code Playgroud)
......但标题仍然在左边.
我试着在这里阅读有关flex的内容,但无法弄清楚要做什么.
我创建了一个扩展方法来encapsule一些其中逻辑这样的(这是一个非常简化的版本):
public static IQueryable<Cargo> ReadyToCarry(this IQueryable<Cargo> q)
{
VehicleType[] dontNeedCouple = new VehicleType[] { VehicleType.Sprinter, VehicleType.Van, VehicleType.Truck };
return q.Where(c => c.DriverId > 0 && c.VehicleId > 0)
.Where(c => c.CoupleId > 0 || dontNeedCouple.Contains(c.Vehicle.Type));
}
Run Code Online (Sandbox Code Playgroud)
所以我可以像这样使用它:
using (var ctx = new MyNiceContext())
{
var readyCargo = ctx.Cargos.ReadyToCarry().OrderBy(c => c.Id).ToList();
// ...more code
}
Run Code Online (Sandbox Code Playgroud)
这很好用,它被转换为SQL并由Entity Framework执行.现在,我还有另一个地方需要货物,这些货物还没有准备好携带,这意味着我需要恰恰相反.
我的想法是这样的:
public static IQueryable<Cargo> NotReadyToCarry(this IQueryable<Cargo> q)
{
return !q.ReadyToCarry(); // ofc this doesn't work...
}
using (var …
Run Code Online (Sandbox Code Playgroud) 如何在Delphi 2009中获取文件的所有者?
我有一个函数,它获取这样的文件属性:
type
TCustomFileInfo= record
CompanyName,
Owner,
SpecialBuild: string;
procedure Clear;
end;
function GetFileInfo(const FileName: string): TCustomFileInfo;
type
PLandCodepage = ^TLandCodepage;
TLandCodepage = record
wLanguage,
wCodePage: word;
end;
var
dummy,
len: cardinal;
buf, pntr: pointer;
lang: string;
begin
len := GetFileVersionInfoSize(PChar(FileName), dummy);
if len = 0 then
RaiseLastOSError;
GetMem(buf, len);
try
if not GetFileVersionInfo(PChar(FileName), 0, len, buf) then
RaiseLastOSError;
if not VerQueryValue(buf, '\VarFileInfo\Translation\', pntr, len) then
RaiseLastOSError;
lang := Format('%.4x%.4x', [PLandCodepage(pntr)^.wLanguage, PLandCodepage(pntr)^.wCodePage]);
// Get Company's name, if available...
if …
Run Code Online (Sandbox Code Playgroud) 我们有一个遗留的VB.NET应用程序.前端正在MVC 5中重新设计,我被分配将业务逻辑抽象为API.
我创建了一个包含一些代码的库来调用API(因此构建MVC 5应用程序的开发人员可以轻松地安装/更新包并使用它).
但我想帮助负责重新设计VB.NET项目的开发人员使用相同的NuGet包来使用API.
是否可以创建一个兼容两者的NuGet包,或者我真的需要制作两个包吗?
我读了一些关于.NET Standard的内容,但我找不到任何关于VB.NET的内容,它看起来只适用于C#(我不确定).
如果可能的话,VB.NET项目是否应该使用与包相同的.net框架版本才能工作?
我刚刚在我的 Azure 应用服务之一中创建了一个“暂存”槽。
在 Azure 门户中,在该插槽的应用程序设置中,我创建了一个新密钥,如下所示:
...并将其设为“插槽设置”,因为我不希望交换该值。
当我在 .NET Core 项目中执行代码时,Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
返回null
. 在本地,只要我在计算机环境变量中设置此值,它就可以工作。
我错过了什么吗?
environment-variables azure azure-web-app-service asp.net-core
我正在尝试在Angular 5应用程序中使用SignalR.
我从DefinitelyTyped安装了这些强类型:
npm install --save @types/jquery
npm install --save @types/signalr
Run Code Online (Sandbox Code Playgroud)
我的packages.json
节目版本2.5.3中的打字稿.
现在我试图像这样使用它:
import { Injectable } from '@angular/core';
@Injectable()
export class SignalRService {
constructor() {}
public ConnectTo(url: string): void {
var hubConnection = $.hubConnection();
var hubProxy = hubConnection.createHubProxy('DashboardHub');
hubProxy.on('Example', (e: any) => {
console.log('worked');
});
hubConnection.start();
}
}
Run Code Online (Sandbox Code Playgroud)
编译器抱怨如下:
error TS2304: Cannot find name '$'.
Run Code Online (Sandbox Code Playgroud)
...即使intellisense可以找到$.hub
:
如果我尝试添加declare var $ :any;
到我的文件,它会编译,但我在浏览器的控制台中收到另一个错误:$.hubConnection is not a function …
我试图获得一个数字的正值而不使用Math.Abs
这样的:
int small = -1000;
Console.WriteLine(small - small - small);
int big = int.MinValue;
Console.WriteLine(big - big - big);
Run Code Online (Sandbox Code Playgroud)
第一个工作正常,我得到1000印刷,但对于第二种情况,它得到-2147483648
而不是积极的2147483648
.
我怀疑这与整数溢出有关,但我认为这没有意义,因为操作的结果不应该溢出整数边界.
例如:
(-2147483648) - (-2147483648) = 0
0 - (-2147483648) = 2147483648
Run Code Online (Sandbox Code Playgroud)
要么
(-2147483648) - (-2147483648) - (-2147483648) = 2147483648
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我已经看过很多lock
用法示例,它通常是这样的:
private static readonly object obj = new object();
lock (obj)
{
// code here
}
Run Code Online (Sandbox Code Playgroud)
是否可以根据类的属性进行锁定?我不想在全球锁与方法调用的任何lock
声明,我想锁定功能只有在作为参数传递的对象具有相同的属性值,将其被在此之前,处理的另一对象.
那可能吗?这有道理吗?
这就是我的想法:
public class GmailController : Controller
{
private static readonly ConcurrentQueue<PushRequest> queue = new ConcurrentQueue<PushRequest>();
[HttpPost]
public IActionResult ProcessPushNotification(PushRequest push)
{
var existingPush = queue.FirstOrDefault(q => q.Matches(push));
if (existingPush == null)
{
queue.Enqueue(push);
existingPush = push;
}
try
{
// lock if there is an existing push in the
// queue that matches the requested one
lock (existingPush) …
Run Code Online (Sandbox Code Playgroud) c# ×5
angular ×2
delphi ×2
delphi-2009 ×2
winapi ×2
.net ×1
asp.net-core ×1
aws-lambda ×1
azure ×1
css ×1
css3 ×1
flexbox ×1
iqueryable ×1
linq ×1
locking ×1
npm ×1
nuget ×1
signalr ×1
typescript ×1
vb.net ×1
windows ×1