小编Lui*_*cia的帖子

azure worker role无法直接启动具有类库的输出类型的项目

我使用azure SDK 2.9在visual studio 2015 update 2中创建了一个新的云服务解决方案

根据我正在阅读的一本书,它说如果我开始一个工作者角色,它应该打开计算模拟器,我应该能够调试我的代码.

但是我收到此错误:无法直接启动具有类库的输出类型的项目

我确切地知道错误意味着什么,并且在托盘图标上已经启动了计算模拟器.

如何调试辅助角色?

.net c# azure azure-worker-roles azure-cloud-services

3
推荐指数
1
解决办法
602
查看次数

将启动和startup.auth代码放在.net框架(而不是.net core)上的位置

我有这个代码:

https://github.com/nbarbettini/SimpleTokenProvider/tree/master/test/SimpleTokenProvider.Test

这是使用 .net CORE 完成的,它是一个带有 .net CORE 的 WEB API。

我需要实现一个具有相同安全性的 WEB API,但使用 .net 框架而不是 dot net core。

在使用 .net Framework 4.5.2 的经典 asp.net Web api 项目中,我需要将 Startup.cs、StartupAUth.cs、Program.cs 中的代码放在哪里?

谢谢

.net c# asp.net asp.net-core

3
推荐指数
1
解决办法
7555
查看次数

.Net Core 中的 DbContextTransaction 在哪里

我需要DbContextTransaction在 .Net Standard 库上的类中使用,我一直无法找到相应的 nuget 包,我正在移植这个https://github.com/mehdime/DbContextScope/tree/master/Mehdime.Entity到 .Net Core,但由于缺少包/依赖项,我只有 2 个编译错误,我不知道如何找到:

错误 CS0246:找不到类型或命名空间名称“MarshalByRefObject”(您是否缺少 using 指令或程序集引用?)(CS0246) (Mehdime.Entity)

错误 CS0246:找不到类型或命名空间名称“DbContextTransaction”(您是否缺少 using 指令或程序集引用?)(CS0246) (Mehdime.Entity)

代码是:

/* 
 * Copyright (C) 2014 Mehdi El Gueddari
 * http://mehdi.me
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */
using System;
using System.Collections.Generic;
using System.Data;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Mehdime.Entity
{
    /// <summary>
    /// As …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework asp.net-core-mvc asp.net-core

3
推荐指数
1
解决办法
9569
查看次数

检测到类型 System.Web.IHttpHandler 试图覆盖现有映射

当我将 asp.net mvc 应用程序复制到我们测试服务器的 IIS 文件夹时,我在该应用程序上遇到以下错误。

在本地它工作得很好:

检测到尝试覆盖名称为“”的 System.Web.IHttpHandler 类型(当前映射到 Microsoft.Reporting.WebForms.HttpHandler 类型到 Microsoft.Reporting.WebForms.HttpHandler 类型)的现有映射。

UnityConfig.cs 代码是这样的:

namespace xxx.Relacionamiento.Web.App_Start
{
    /// <summary>
    /// Specifies the Unity configuration for the main container.
    /// </summary>
    public class UnityConfig
    {
        #region Unity Container
        private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() =>
        {
            var container = new UnityContainer();
            RegisterTypes(container);
            return container;
        });

        /// <summary>
        /// Gets the configured Unity container.
        /// </summary>
        public static IUnityContainer GetConfiguredContainer()
        {
            return container.Value;
        }
        #endregion

        /// <summary>Registers the type …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc unity-container reporting-services

3
推荐指数
1
解决办法
960
查看次数

在此处字符串标头之后但在行尾之前不允许使用任何字符

我在我的脚本中使用这个 aa 基础:

https://www.nwcadence.com/blog/vststfs-rest-api-the-basics-and-working-with-builds-and-releases

我的脚本如下

Param(
   [string]$vstsAccount = "abc",
   [string]$projectName = "abc",
   [string]$user = "",
   [string]$token = "xyz"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$verb = "POST"


$body = @"{

    "definition": {
         "id": 20
    }
}"@


$uri = "https://$($vstsAccount).visualstudio.com/DefaultCollection/$($projectName)/_apis/build/builds?api-version=4.1"
$result = Invoke-RestMethod -Uri $uri -Method $verb -ContentType "application/json" -Body (ConvertTo-Json $body)  -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Run Code Online (Sandbox Code Playgroud)

但是我在上面的博客文章中使用的主体定义存在语法错误。

> o characters are allowed after a here-string header but before the end
> of …
Run Code Online (Sandbox Code Playgroud)

rest powershell azure-devops

3
推荐指数
2
解决办法
8817
查看次数

方法调用失败,因为 [System.Management.Automation.PSObject] 不包含名为“op_Addition”的方法

我正在尝试将共享点列表中的一些数据导出到 csv,但出现此错误:

$ListItemCollection | 导出-CSV "D:\LX.csv" -NoTypeInformation

Method invocation failed because [System.Management.Automation.PSObject] doesn't contain a method named 'op_Addition'.
At line:20 char:2
+     $ListItemCollection += $ExportItem
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
Run Code Online (Sandbox Code Playgroud)

代码很简单

$URL = "https://mysite"
$List = "Page Contents"

$Web = Get-SPWeb $URL

$web
$spList = $Web.Lists[$List]
$Items = $spList.GetItems()


$listItems = $spList.Items

foreach($item in $listItems) {

    $ExportItem = New-Object PSObject 
    $ExportItem | Add-Member -MemberType NoteProperty -name "PageID" -value $item["PageID"]
    $ExportItem | Add-Member …
Run Code Online (Sandbox Code Playgroud)

powershell sharepoint

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

dotnet 核心应用程序,如何使用 appsettings 文件构建到输出文件夹

我有这个错误:

Unhandled Exception: System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The physical path is '/ONEDRIVE/OneDrive - SE/LuloTV/Azure Search/DemoSearchIndexer/bin/Debug/netcoreapp2.2/appsettings.json'.
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at DemoSearchIndexer.Program.Main(String[] args) in /ONEDRIVE/OneDrive - SE/LuloTV/Azure Search/DemoSearchIndexer/Program.cs:line 16
Run Code Online (Sandbox Code Playgroud)

JSON 文件存在于源代码目录中,但是,它看起来需要在二进制文件夹的某处找到该文件。

在使用 dotnet run 运行应用程序之前,我执行了 dotnet build,假设它将 JSON 文件复制到输出构建文件夹,但它没有。

在此处输入图片说明

代码是这样的:

using System;
using System.Linq;
using System.Threading;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Spatial;

namespace DemoSearchIndexer
{
    class Program
    {
        static void Main(string[] args)
        {
            IConfigurationBuilder builder = new …
Run Code Online (Sandbox Code Playgroud)

.net c# .net-core

3
推荐指数
1
解决办法
1232
查看次数

Swagger 2.0 不支持:路径“api/Client”和方法“GET”的多个操作

在我的 web api 中,我有 2 种获取方法,一种获取所有客户端,一种通过 ID 获取客户端

  [HttpGet]
    public async Task<IHttpActionResult> GetClients()
    {
        var telemetry = new TelemetryClient();
        try
        {
            var roles = await CosmosStoreHolder.Instance.CosmosStoreClient.Query().ToListAsync();
            return Ok(roles);
        }
        catch (System.Exception ex)
        {
            string guid = Guid.NewGuid().ToString();
            var dt = new Dictionary<string, string>
            {
                { "Error Lulo: ", guid }
            };

            telemetry.TrackException(ex, dt);
            return BadRequest("Error Lulo: " + guid);
        }
    }

    [HttpGet]
    public async Task<IHttpActionResult> GetClient(string clientId)
    {     
        var telemetry = new TelemetryClient();
        try
        {
            var clientStore = CosmosStoreHolder.Instance.CosmosStoreClient;
            var …
Run Code Online (Sandbox Code Playgroud)

c# swagger swashbuckle

3
推荐指数
1
解决办法
3200
查看次数

收到 B 的正则表达式名称

我有以下几行

John SMith: A
Pedro Smith: B
Jonathan B:  A
John B: B
Luis Diaz: A
Scarlet Diaz: B
Run Code Online (Sandbox Code Playgroud)

我需要获得所有获得 B 的学生姓名。

我试过这个,但它不能 100%

x = re.findall(r'\b(.*?)\bB', grades)
Run Code Online (Sandbox Code Playgroud)

python regex

3
推荐指数
1
解决办法
73
查看次数

做出完整的圆形路径,最短路径运动?

我在接受采访时得到了这个问题,但我无法解决.

你有一条环形公路,有N个加油站.你知道每个车站有多少气体.你知道从一个站到下一个站所需的气体量.你的车从0气开始.问题是:创建一个算法,知道你必须从哪个加油站开始驾驶以完成圆形路径.它没有指定您必须访问所有站.你只能顺时针驾驶.

我不得不在c#中做到这一点

我开始的唯一代码是GasStation实体

class GasStation
  int gasAtStation;
  int gasToMoveToNextStationNeeded;
  string nameOfGasStation;


GasTation wheretoStart(List<GasStation> list)
{

}
Run Code Online (Sandbox Code Playgroud)

我是这样做的:

static void Main(string[] args)
        {
            int[] gasOnStation = {1, 2, 0, 4};
            int[] gasDrivingCostTonNextStation = {1, 1,2, 1};

            FindStartingPoint(gasOnStation, gasDrivingCostTonNextStation);

        }

        static void FindStartingPoint(int[] gasOnStation, int[] gasDrivingCosts)
        {
            // Assume gasOnStation.length == gasDrivingCosts.length
            int n = gasOnStation.Length;
            int[] gasEndValues = new int[n];
            int gasValue = 0;
            for (int i = 0; i < n; i++)
            {
                gasEndValues[i] = gasValue;
                gasValue += gasOnStation[i]; …
Run Code Online (Sandbox Code Playgroud)

c# algorithm

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