小编mon*_*_za的帖子

带有Chrome Debugger扩展的Visual Studio代码中的"未验证的断点"

我正在尝试使用Chrome调试器扩展在Visual Studio代码中调试我的Typescript代码,但是我在断点上收到"未验证的断点"消息,并且执行不会在我的断点上停止.

这是我的launch.json文件:

{
    linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:4200",
            "sourceMaps": true,
            "webRoot": "${workspaceFolder}"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

应用版本:

  • Visual Studio代码:1.25.1
  • Chrome:67.0.3396.99

我看到如果您有以下Chrome版本__CODE__,则会收到此错误消息.如果我打开Chrome并导航到__CODE__,我可以看到我的Chrome版本__CODE__.当我导航到__CODE__Visual Studio Code时,Chrome的版本显示为__CODE__.

不确定这是否相关,但如何更新Visual Studio Code中显示的Chrome版本,以反映正确的Chrome版本?

关于如何解决这个问题的任何其他建议?

debugging typescript visual-studio-code vscode-settings

72
推荐指数
7
解决办法
5万
查看次数

找不到'@ angular/common/http'模块

我正在关注Angular关于Http的这个基础教程.

正如可以在"设置:安装模块"部分中看到的那样,他们导入HttpClientModule,如下所示:

import {HttpClientModule} from '@angular/common/http';
Run Code Online (Sandbox Code Playgroud)

当我在我的项目中尝试这个时,我收到以下错误:"找不到模块'@ angular/common/http'".

我尝试导入以下模块,如下所示:

import { HttpModule } from '@angular/http';
Run Code Online (Sandbox Code Playgroud)

然后是我的进口部分:

imports: [
    HttpModule
],
Run Code Online (Sandbox Code Playgroud)

现在的问题是,我无法将此HttpModule注入我的服务对象,并且我收到以下错误:"找不到模块HttpModule".

这是我的服务类:

import { Injectable, OnInit } from '@angular/core';
//Custom Models
import { Feed } from '../Models/Feed';

@Injectable()
export class FeedsService {
    constructor(private httpClient: HttpModule) {}
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

更新 当我意识到我无法按照教程导入模块时,我应该做的就是运行npm update命令,更新我的所有包.

node-modules angular

53
推荐指数
2
解决办法
11万
查看次数

将pdb文件包含到我的nuget(nupkg)文件中

我正在使用MSBuild生成我的nuget包.

是否需要设置任何命令,允许它包含我的.pdb文件,以便在调试时插入源代码?

我不希望源文件包含在拉入nuget包的项目中.

c# msbuild visual-studio nuget

34
推荐指数
4
解决办法
1万
查看次数

ENOENT:没有node_modules\jquery\dist\jquery.min.js这样的文件或目录

我不确定我做错了什么:

我在这里按照教程,但我不断收到以下错误:

ENOENT:没有这样的文件或目录,打开'C:\ Users\andrewkp\Documents\VSCode\Projects \node_modules\jquery\dist\jquery.min.js'错误:ENOENT:没有这样的文件或目录,打开'C:\用户\ andrewkp \文档\ VSCode \项目\node_modules\jQuery的\ DIST\jquery.min.js'

这是我的angular.json文件.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "MyProjectName": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/MyProjectName",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css",
              "../node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "../node_modules/jquery/dist/jquery.min.js",
              "../node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                } …
Run Code Online (Sandbox Code Playgroud)

angularjs visual-studio-code angular-cli angular-cli-v6

15
推荐指数
1
解决办法
2万
查看次数

无法解析“Swashbuckle.AspNetCore.Swagger.ISwaggerProvider”类型的服务

我正在启动一个新的CoreWeb API,并希望添加Swagger到我的应用程序中。

我现在的环境:

  • .Net 核心 3.0
  • Swashbuckle.AspNetCore 5.0.0-rc4

这是我的Startup.cs课程和配置:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();

        //AK: Enable CORS
        //CORS should be configured on host server.
        services.AddCors(setupAction =>
        {
            setupAction.AddPolicy(DevCorsPolicyName,
                builder =>
                {
                    builder.WithOrigins("*").AllowAnyHeader().AllowAnyMethod();
                });
        });

        #region Configuration

        //Configuration File
        services.Configure<AppSettingConfiguration>(Configuration.GetSection("AppSettings"));
        //AutoMapper
        services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

        //Configure Swagger
        services.ConfigureSwaggerGen(c =>
        {
            c.SwaggerDoc("v3", new OpenApiInfo
            {
                Title = "GTrackAPI",
                Version = "v3"
            });
        });

        #endregion

        #region Dependency Injection

        //Database context and repository
        services.AddDbContext<IGTrackContext, GTrackContext>(builder =>
        {
            builder.UseSqlServer(connectionString: Configuration.GetConnectionString("gtrackConnection"), sqlServerOptionsAction: …
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection swagger asp.net-core asp.net-core-webapi

11
推荐指数
2
解决办法
2万
查看次数

使用 Angular 下载 .xls 文件:JSON.parse (&lt;anonymous&gt;) 位置 0 处的 JSON 中的意外令牌 P

我有一个返回以下服务器方法byte[]xls存储在文件Azure Blob Storage

[FunctionName("ReadBatchFile")]
        public async static Task<HttpResponseMessage> ReadBatchFile([HttpTrigger(AuthorizationLevel.Function, WebRequestMethods.Http.Get, Route = "Agreements/ReadBatchFile")]HttpRequestMessage req, TraceWriter log)
        {
            try
            {
                var fileName = req.GetQueryNameValuePairs()
                   .FirstOrDefault(q => string.Compare(q.Key, "fileName", true) == 0)
                   .Value;
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new ByteArrayContent(await AzureHelpers.ReadFromBlobStorage(fileName));  //returns byte[] 
                response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = fileName };
                response.Content.Headers.ContentType =
                    new MediaTypeHeaderValue("application/octet-stream");
                return response;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                req.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return req.CreateResponse(HttpStatusCode.BadRequest);
        }
Run Code Online (Sandbox Code Playgroud)

从上面可以看出, the response.Contentis set …

c# json http typescript angular

10
推荐指数
2
解决办法
9437
查看次数

Observable.subscribe() 与带有 async/await 的 Promise

考虑在 aService中查询 Web 服务的以下两种方法:

getAssessmentById(id: number): Observable<MotorAssessorReport> {
  const url = environment.endPoints.assessment.base + 
    environment.endPoints.assessment.assessmentById + id;
  return this.httpClient.get<MotorAssessorReport>(url)
}

async getAssessmentByIdAsync(id: number): Promise<MotorAssessorReport> {
  const url = environment.endPoints.assessment.base + 
    environment.endPoints.assessment.assessmentById + id;
   const data = await this.httpClient.get<MotorAssessorReport>(url).toPromise();
  return data;
}
Run Code Online (Sandbox Code Playgroud)

第一个方法,getAssessmentById返回一个observable. 第二种方法,getAssessmentByIdAsync,返回一个promise

subscribeToAssessment() {
 this.assessmentService.getAssessmentById(this.assessmentId).subscribe(result => 
 {
    this.assessment = result;
 });
}

async fetchAssessment() {
  this.assessment = await this.assessmentService.getAssessmentByIdAsync(this.assessmentId);
}
Run Code Online (Sandbox Code Playgroud)

我一直使用第一种方法,返回一个Observable<T>,并订阅我的调用代码。

我最近才真正开始明白,只有当您期望返回多个结果时,才应该真正使用这种方法。换句话说,当使用 a 时Promise<T>,回调被调用的最大数量只有一次。

由于我一直期望我的服务器总是只返回一次,我的方法是错误的,我应该使用这种Promise<T> …

promise observable rxjs angular

7
推荐指数
3
解决办法
5043
查看次数

Cosmos DB 数据应该如何构建

我目前正在与一个开发团队合作,将 CosmosDB 实现为后端存储,我对它的实际用途有一些疑问。

我知道这些文档应该是扁平结构的,但这到底是什么意思?

当数据确实是相关的并且彼此非常依赖时,这种设计是否正确,或者 SQL 数据库是否更适合?

零售产品

{
    "RetailProductId": "123",
    "FriendlyName": "TestRetailProduct",
    "WholeSaleProductId": "100"
}
Run Code Online (Sandbox Code Playgroud)

批发产品

{
    "WholeSaleProductId": "100",
    "ProviderID": "112233445566",
    "PhysicalItemsIds": ["1000", "2000", "3000"]
}
Run Code Online (Sandbox Code Playgroud)

提供者

{
    "ProviderId": "112233445566",
    "Description": "ProviderA"
}
Run Code Online (Sandbox Code Playgroud)

RetailProduct 或 WholeSaleProduct 还链接了更多文档,但这只是为了提供概述。

像这样存储数据,被认为是像 CosmosDB 这样的数据库的良好实践

database azure azure-cosmosdb

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

在任务上使用akka.net PipeTo()进行异常处理

参考Akka.Net文档,PipeTo()在处理异步作业时首选使用.

当处理返回的函数时Task<T>,我可以处理失败事件,没问题.

问题是,当处理一个不返回任何类型但只有Task一个PipeTo函数的函数时,仍然会调用该函数,但它不是包含失败句柄的重载,而是现在说明如下:'由于此任务没有结果,只有例外情况会通过管道传送给收件人.'

这是否意味着,如果我有以下代码:

public class RepositoryComponent : IRepositoryComponent
{
    private SqlSettings _sqlSettings;

    public RepositoryComponent(SqlSettings sqlSettings)
    {
        _sqlSettings = sqlSettings;
    }

    public async Task InsertJobAsync(RetryModel job)
    {
        try
        {
            await... //some logic
        }
        catch { throw; }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的演员:

public class RepositoryActor : ActorBase
{
    private IRepositoryComponent _repoComponent;
    private ActorSelection _retryActor;

    public RepositoryActor(IRepositoryComponent repoComponent) : base()
    {
        _repoComponent = repoComponent;
    }

    public override void Listening()
    {
        Receive<RepositoryMessages.GenericRequestNoReturn>(x => InvokeRequest(x));
        Receive<RepositoryMessages.GenericRequestWithResponseType>(x => …
Run Code Online (Sandbox Code Playgroud)

c# akka.net microservices

4
推荐指数
1
解决办法
812
查看次数

无效的延续令牌 CosmosDB

我正在运行一个查询 CosmosDB 实例的 Azure 函数。

我正在尝试使用延续令牌实现分页,但在使用延续令牌调用我的函数时不断收到以下响应:

Message": "发生错误。", "ExceptionMessage": "无效的连续令牌\r\nActivityId: 0f79a65f-a9d2-49a8-8a9c-d33a8526bec8,Microsoft.Azure.Documents.Common/2.0.0.0,documentdb-dotnet- sdk/1.22.0 主机/32位 MicrosoftWindowsNT/6.2.9200.0

这是我的 Azure 函数:该函数最初将在没有令牌的情况下调用,并且根据第二页的请求,将传入令牌。

[FunctionName("GetAllPaged")]
public static async Task<HttpResponseMessage> ReadAll(
    [HttpTrigger(AuthorizationLevel.Function, "get", Route = "GetAllPaged/{pageSize?}/{token?}")]HttpRequestMessage req,
    int? pageSize, string token, ILogger log, [Inject]IComponent<EventModel> component)
{
    try
    {
        log.LogInformation("Get all events");

        var response = await component.GetAll_Paged(pageSize, token);

        return req.CreateResponse(HttpStatusCode.OK, response);
    }
    catch (Exception ex)
    {
        log.LogError(ex.Message, ex);
        return req.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
    }
}
Run Code Online (Sandbox Code Playgroud)

在我首次调用 Azure 函数时,使用 URL http://localhost:7071/api/Event/GetAllPaged/3,我得到以下响应:

    {
"Continuation": {
    "token": "CDhbANnikwAGAAAAAAAAAA==",
    "range": {
        "min": "",
        "max": …
Run Code Online (Sandbox Code Playgroud)

c# pagination azure-functions azure-cosmosdb azure-cosmosdb-sqlapi

4
推荐指数
1
解决办法
2445
查看次数