标签: .net-core

如何调试点击本地主机 asp.net core API 的 Xamarin iOS 应用程序

我有一个 Xamarin Forms 应用程序(Android 和 iOS,而不是 UWP),它可以访问我创建的 DotNetCore 2.1 API(在 下运行http://localhost:5000)。所有这些都是使用 Visual Studio 2017 开发的。

我可以使用在 Android 端转换http://10.0.2.2:5000为“localhost”的地址来调试 Android 端。所以我可以从 Android 模拟器中很好地调用我的 API。

问题出在iOS端。

iOS 模拟器实际上在 Mac 上运行,因此无法看到我的 Windows 机器运行 API。

如何配置我的 Windows/Mac 计算机以便能够访问我的本地 API?

我可以从 Mac 上 ping 我的 Windows 机器,但目前仅此而已。

xamarin xamarin.forms .net-core

0
推荐指数
1
解决办法
1036
查看次数

dotnet core 2.1 angular 应用程序 - 重命名 ClientApp 文件夹

我不得不在 dotnet core 2.1 单页应用程序模板中重新设计一个 angular 应用程序。

我在普通“ClientApp”文件夹旁边的一个新文件夹“Frontend”中完成了它。在本地它工作正常,但是当我部署它或尝试通过“dotnet publish”发布它时,它总是使用 ClientApp 文件夹。

是否可以分别替换重命名 ClientApp 文件夹?

.net-core angular

0
推荐指数
1
解决办法
781
查看次数

C# Core 2.1 使用 2 个 CPU

I'm Currently building an application which relies heavily on running multithreaded. I'm Currently spawning as many threads as the system has cores using the environment.ProcessorCount constant, but when I run the application on our server which has 2 separate CPUs (Intel Xeon E5-2620) all threads work on the first CPU while the second CPU idles. Is it possible to utilize the second CPU in one process or do I need to split the process and force the utilisation with Processor …

c# multithreading multiprocessing .net-core

0
推荐指数
1
解决办法
1386
查看次数

EF Core 无效的列名(外键)

我正在使用 EF Core 2.2 错误代码

var ClientCase= _context.Client_Cases.Include(a=>a.Case_Sessions). FirstOrDefault(x => x.Id == id);
Run Code Online (Sandbox Code Playgroud)

错误

System.Data.SqlClient.SqlException: '无效的列名 'Client_CaseId'。无效的列名“Case_LevelId”。无效的列名“Client_CaseId”。无效的列名“Court_CircleId”。无效的列名“Court_HallId”。

实体

1- 父 Client_Case

public class Client_Cases
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public long Id { get; set; }        
    public string Opponent { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime Recieve_Date { get; set; }
    [ForeignKey("Clients")]
    public long? ClientID { get;set;}
    public Clients Client { get; set; }
    [ForeignKey("Case_Levels")]
    public long? LevelID { get; set; }
    public virtual Case_Levels Case_Levels …
Run Code Online (Sandbox Code Playgroud)

c# core .net-core ef-core-2.2

0
推荐指数
1
解决办法
3745
查看次数

GetHashCode 是否保证在对象的生命周期内相同?

我讨厌打败一匹 。在@eric-lippert 的博客中,他说:

一个对象的哈希值在其整个生命周期内是相同的

然后跟进:

然而,这只是一个理想情况的指导方针

所以,我的问题是这个。

对于 POCO(没有被覆盖)或框架(如FileInfoProcess)对象,方法的返回值是否GetHashCode()保证在其生命周期内相同?

PS 我说的是预先分配的对象。 var foo = new Bar();foo.GetHashCode()始终返回相同的值。

c# .net-core

0
推荐指数
1
解决办法
231
查看次数

无法创建迁移,因为无法识别 EntityFramework.Design 包

我安装了EntityFrameworkCore.Design运行以下。

Install-Package Microsoft.EntityFrameworkCore.Design -Version 3.0.0-preview6.19304.10
Run Code Online (Sandbox Code Playgroud)

它似乎已安装,我可以在VS中看到以下内容。

[图片]

但是,当我尝试使用创建迁移时

dotnet ef migrations add Init
Run Code Online (Sandbox Code Playgroud)

我等待了很长时间,然后出现以下错误。

您的启动项目“Web”未引用 Microsoft.EntityFrameworkCore.Design。这个包是 Entity Framework Core Tools 工作所必需的。确保您的启动项目正确,安装包,然后重试。

当我检查Web.proj文件时,我会看到以下部分。

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.0.0-preview6.19307.2" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview6.19304.10">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview6.19304.10" />
  <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
  <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0-rc2" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

如何确保电脑看到包裹?

c# entity-framework-core .net-core .net-core-3.0 ef-core-3.0

0
推荐指数
1
解决办法
3761
查看次数

如何修复:“IDataProtectionBuilder”不包含“PersistKeysToDbContext”的定义并且没有可访问的扩展

我正在尝试使用 services.AddDataProtection() 中的 PersistKeysToDbContext 扩展将密钥持久化到 SQL。目前我们正在使用 PersistKeysToStackExchangeRedis,它工作得非常好,但是确定需要将其移至 DB。

我们正在使用一个 .net Core 2.2 项目,并添加了以下引用:

Microsoft.AspNetCore.DataProtection.EntityFrameworkCore (2.2.0) Microsoft.AspNetCore.DataProtection.Extensions (2.2.0) Microsoft.AspNetCore.DataProtection.StackExchangeRedis (2.2.0) (显然是针对当前功能)

Microsoft.EntityFrameworkCore (2.2.0)

services.AddDataProtection().PersistKeysToDbContext<ApplicationDbContext>();
Run Code Online (Sandbox Code Playgroud)

我从编译器收到以下错误:

“IDataProtectionBuilder”不包含“PersistKeysToDbContext”的定义,并且找不到接受“IDataProtectionBuilder”类型的第一个参数的可访问扩展方法“PersistKeysToDbContext”(您是否缺少 using 指令或程序集引用?)

c# entity-framework-core .net-core

0
推荐指数
1
解决办法
1648
查看次数

什么是 C# 中的属性访问器递归?

什么是 C# 中的属性访问器递归?我看到有关如何解决它的文章,但想要它是什么的纯技术定义。

有关如何解决它的资源:

c# 属性设置器主体,无需声明类级属性变量

.net c# class software-design .net-core

0
推荐指数
1
解决办法
366
查看次数

Azure Functions 和 Azure Durable Function 有什么区别

持久函数是否会在活动被调用之前唤醒?

我是关于实现调度程序的,而是使用其他库,例如 Hangfire 或 Quartz。我想实现作为调度程序的持久功能。我缺少的部分是,函数中发生了什么?该函数是否在下一次活动调用之前大喊大叫?每一项都叫执行?

[FunctionName("SchedulerRouter")]
public static async Task<HttpResponseMessage> HttpStart(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
    [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
{
    var data = await req.Content.ReadAsAsync<JObject>();
    var instanceId = await starter.StartNewAsync(FunctionsConsts.MAIN_DURABLE_SCHEDULER_NAME, data);
    return starter.CreateCheckStatusResponse(req, instanceId);
}
Run Code Online (Sandbox Code Playgroud)

c# azure .net-core azure-functions azure-durable-functions

0
推荐指数
1
解决办法
2152
查看次数

C# 使用动态 lambda 但在选择要使用的方法时得到不明确的匹配

根据 Pashov 的博客文章,我有以下静态方法用于在过滤器选项之间进行选择。

public static class ExpressionRetriever  
    {  
        private static MethodInfo containsMethod = typeof(string).GetMethod("Contains");  
        private static MethodInfo startsWithMethod = typeof(string).GetMethod("StartsWith", new Type[] { typeof(string) });  
        private static MethodInfo endsWithMethod = typeof(string).GetMethod("EndsWith", new Type[] { typeof(string) });



    public static Expression GetExpression<T>(ParameterExpression param, ExpressionFilter filter)  
    {  
        MemberExpression member = Expression.Property(param, filter.PropertyName);  
        ConstantExpression constant = Expression.Constant(filter.Value);  
        switch (filter.Comparison)  
        {  
            case Comparison.Equal:  
                return Expression.Equal(member, constant);  
            case Comparison.GreaterThan:  
                return Expression.GreaterThan(member, constant);  
            case Comparison.GreaterThanOrEqual:  
                return Expression.GreaterThanOrEqual(member, constant);  
            case Comparison.LessThan:  
                return Expression.LessThan(member, constant);  
            case Comparison.LessThanOrEqual:  
                return Expression.LessThanOrEqual(member, …
Run Code Online (Sandbox Code Playgroud)

c# reflection ambiguous-call .net-core

0
推荐指数
1
解决办法
549
查看次数