小编Dav*_*New的帖子

OwinStartup没有开始......为什么?

我在ASP.NET MVC 5站点上有以下类:

[assembly: OwinStartup(typeof(MVCSite.Startup))]
namespace MVCSite {

  public partial class Startup {

    public void Configuration(IAppBuilder application) {

      application.UseCookieAuthentication(new CookieAuthenticationOptions {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login")
      });

      application.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

在Web.Config上我有以下内容:

<add key="owin:AutomaticAppStartup" value="false"/>
Run Code Online (Sandbox Code Playgroud)

我在Startup.Configuration中有一个断点但这不会触发......

知道为什么吗?

asp.net-mvc owin asp.net-mvc-5

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

重命名Azure存储表?

是否无法重命名Azure存储表?

我似乎无法在网上找到任何东西(甚至不是cmdlet).Visual Studio Server Explorer,Cloud Storage Studio或TableXplorer中没有此选项.

azure azure-table-storage

13
推荐指数
2
解决办法
4369
查看次数

用于更新整个聚合的通用存储库

我正在使用存储库模式来提供对聚合的访问和保存.

问题是更新由实体关系组成的聚合.

例如,采取OrderOrderItem关系.聚合根Order管理自己的OrderItem集合.OrderRepository因此,一个人将负责更新整个聚合(没有OrderItemRepository).

使用Entity Framework 6处理数据持久性.

更新存储库方法(DbContext.SaveChanges()在别处发生):

public void Update(TDataEntity item)
{
    var entry = context.Entry<TDataEntity>(item);

    if (entry.State == EntityState.Detached)
    {
        var set = context.Set<TDataEntity>();

        TDataEntity attachedEntity = set.Local.SingleOrDefault(e => e.Id.Equals(item.Id));

        if (attachedEntity != null)
        {
            // If the identity is already attached, rather set the state values
            var attachedEntry = context.Entry(attachedEntity);
            attachedEntry.CurrentValues.SetValues(item);
        }
        else
        {
            entry.State = EntityState.Modified;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,仅Order更新实体,而不更新其关联的OrderItem …

domain-driven-design entity-framework repository-pattern onion-architecture entity-framework-6

13
推荐指数
2
解决办法
7747
查看次数

无法加载文件或程序集ServiceRuntime 2.4.0.0

升级我们的项目以使用Azure SDK 2.5后,我在部署到Azure(Web角色)时遇到以下运行时异常:

无法加载文件或程序集'Microsoft.WindowsAzure.ServiceRuntime,Version = 2.4.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该系统找不到指定的文件.

NuGet引用的其中一个软件包仍在引用ServiceRuntime 2.4.0.0.根据我的理解,我需要做的就是bindingRedirect在我们的创建中web.config:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0"/>
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用.例外仍然存在.有人可以提供指导吗?

azure azure-web-roles azure-sdk-.net azure-service-runtime

13
推荐指数
1
解决办法
3549
查看次数

MSB3644找不到框架的引用程序集

我收到以下MSB3644并发症错误:

找不到框架".NETFramework,Version = v4.0"的引用程序集.要解决此问题,请为此框架版本安装SDK或Targeting Pack,或者将应用程序重新定位到已安装SDK或Targeting Pack的框架版本.请注意,程序集将从全局程序集缓存(GAC)中解析,并将用于代替引用程序集.因此,您的程序集可能无法正确定位到您想要的框架.

从我在这里读到的,这是由于我的机器上的程序集存储在"程序文件"而不是"程序文件(x86)"中.FrameworkPathOverrideMSBuild上的属性可以修复它.

我已经尝试将此属性(FrameworkPathOverride)添加到csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\..\tools\common.props" />
  <PropertyGroup>
    <TargetFrameworks>net40;net45;netstandard1.2</TargetFrameworks>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
    <FrameworkPathOverride>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0</FrameworkPathOverride>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
    <DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

那个错误然后消失了,但我的所有类型和命名空间都无法解决,我也得到了这个构建警告:

MSB3270正在构建"AMD64"的项目的处理器体系结构与参考"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll","x86"的处理器体系结构之间存在不匹配.这种不匹配可能会导致运行时故障.请考虑通过Configuration Manager更改项目的目标处理器体系结构,以便在项目和引用之间调整处理器体系结构,或者依赖于具有与项目的目标处理器体系结构相匹配的处理器体系结构的引用.

将项目的目标框架设置为x86后,警告消失,但仍然没有类型或命名空间可以解析.

我安装了所有必要的框架:

在此输入图像描述

我在Windows 10上使用Visual Studio 2017.

msbuild assemblies visual-studio visual-studio-2017 .net-standard

13
推荐指数
1
解决办法
5885
查看次数

为什么List <T> .ForEach()实现for循环?

我不明白为什么List<T>.ForEach()扩展方法for在引擎盖下实现了一个循环.这开辟了收集被修改的可能性.foreach在这种情况下,法线会抛出异常,所以肯定会ForEach()以同样的方式做出反应吗?

如果你因为某种原因必须改变一个集合,那么你肯定应该在循环中手动迭代集合for吗?

这里foreach和之间似乎有一点语义矛盾List<T>.ForEach().

我错过了什么吗?

.net c# foreach list

12
推荐指数
3
解决办法
1127
查看次数

ASP.NET 5 Web应用程序作为Azure Web角色?

我们的解决方案中有一个ASP.NET 5 Web应用程序.

通常,我们可以右键单击Cloud Service"角色"项,并从解决方案中的现有项目添加新角色.

但它不能将此项目标识为Web角色:

在解决方案中添加Web角色项目...

我们如何在Azure Web角色中托管ASP.NET 5项目?

编辑:我们正在使用Azure SDK 2.7

azure azure-sdk-.net visual-studio-2015 .net-4.6 asp.net-core

12
推荐指数
1
解决办法
1583
查看次数

每个事务创建CloudTableClient和CloudTable的新实例

在做了一些研究之后,我仍然不确定如何最好地保持与Azure Table Storage的"连接".应该CloudTableClientCloudTable实例跨请求被重用?

我们在公共的高流量API背后使用Table Storage.我们需要高读取可用性和性能.所有查询都是POINT查询(分区键和行键都可用),响应支付的大小很小(小于1千字节).写性能不是一个大问题.API上的每个请求都可以在几个分区中读取最多10个点查询.

从我的阅读中,我了解到以下内容:

  • CloudTableClient不是线程安全的,应该为每个事务创建.显然,这不应该在连续重建时妨碍性能.

  • CloudTable因此,还必须为每个事务创建一个实例.

这些是正确的假设吗?

因此CloudTableClient,我正在重新初始化并CloudTable满足每一项要求.这感觉很浪费.

见实施:

public class EntityStorageComponent : IEntityComponent
{
    private CloudStorageAccount storageAccount;

    public CloudTable Table
    {
        get
        {
            var tableClient = storageAccount.CreateCloudTableClient();

            ServicePoint tableServicePoint = ServicePointManager.FindServicePoint(storageAccount.TableEndpoint);
            tableServicePoint.UseNagleAlgorithm = false;
            tableServicePoint.ConnectionLimit = 100;

            var context = new OperationContext();
            context.Retrying += (sender, args) =>
            {
                Debug.WriteLine("Retry policy activated");
            };

            // Attempt delays: ~200ms, ~200ms, ~200ms
            var requestOptions = new TableRequestOptions
            {
                RetryPolicy = …
Run Code Online (Sandbox Code Playgroud)

azure azure-storage azure-table-storage

12
推荐指数
1
解决办法
2027
查看次数

VS 2015:性能向导中禁用了性能分析工具

我想对应用程序的性能进行抽样,但尝试使用性能向导启动新的性能分析会话时,各种工具(如CPU使用率和应用程序时间轴)不可用:

分析工具

我正在使用Visual Studio 2015 Professional.该应用程序使用的是ASP.NET 5 RC1,并且是从Kestrel(而不是IIS)运行的.

为什么会发生这种情况?

.net visual-studio-2015 dnx asp.net-core asp.net5

12
推荐指数
1
解决办法
1376
查看次数

使用ASP.NET Core库禁用Application Insights采样

我需要保留所有遥测,因为我们将其用于分析.

根据这篇文章,我可以运行以下Analytics查询来确定抽样率:

requests 
 | where timestamp > ago(1d)
 | summarize 100/avg(itemCount) by bin(timestamp, 1h) 
 | render areachart 
Run Code Online (Sandbox Code Playgroud)

结果显示一些严重抽样,特别是在白天只保留了约十分之一的项目:

采样

让我感到困惑的是,Azure Portal阻止采样设置为100%:

Azure门户洞察

也许这只反映了摄取采样?自适应采样仍可能在服务器上进行.

如何使用Application Insights的ASP.NET核心库完全禁用采样?(即Microsoft.ApplicationInsights.AspNetCore 1.0.2)

目前,这是我能找到的唯一配置,并且没有任何取样:

var appInsightsConfiguration = new ConfigurationBuilder()
    .AddApplicationInsightsSettings(
        developerMode: false,
        instrumentationKey: Configuration["ApplicationInsights:InstrumentationKey"])
    .Build();

services.AddApplicationInsightsTelemetry(appInsightsConfiguration);
Run Code Online (Sandbox Code Playgroud)

asp.net-core-mvc azure-application-insights asp.net-core asp.net-core-1.0

12
推荐指数
1
解决办法
4933
查看次数