小编Tom*_*ing的帖子

从 .net core 2.1 Web 应用程序使用 WCF 服务

我有一个成功使用 WCF 服务的 .net 框架应用程序,当我尝试将设置复制到我的 .net 标准 2.0 类库(由 .net core 2.1 Web 应用程序使用)时,我收到各种错误,具体取决于如何我设置了。

首先,这是工作的消费者配置:

<netTcpBinding>
<binding name="netTcpBinding_Service" closeTimeout="00:10:00" openTimeout="00:40:00" receiveTimeout="00:32:00" sendTimeout="00:10:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  <reliableSession ordered="true" inactivityTimeout="00:10:00" />
  <security mode="TransportWithMessageCredential">
    <message clientCredentialType="Certificate" algorithmSuite="Default" />
    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
  </security>
</binding>
</netTcpBinding>
<behaviors>
  <endpointBehaviors>
    <behavior name="ClientBehavior">
      <clientCredentials>
        <clientCertificate findValue="Client" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
        <serviceCertificate>
          <defaultCertificate findValue="Server" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
          <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck" />
        </serviceCertificate>
      </clientCredentials>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </endpointBehaviors>
</behaviors> …
Run Code Online (Sandbox Code Playgroud)

c# wcf nettcpbinding .net-core-2.1

6
推荐指数
0
解决办法
2175
查看次数

msbuild 找不到 project.assets.json

我有一个 ASP.NET Core 应用程序,我希望使用 MSBuild 15 在 jenkins 机器上构建它。

当我尝试构建时,出现以下错误:

C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198, 5): error NETSDK1004: Assets file 'C:\sync\Src\Util\未找到 myUtil\ob j\project.assets.json'。运行 NuGet 包还原以生成此文件

我知道我需要以某种方式进行 nuget restore,但我未能使其正常工作。

我的构建过程:使用以下命令运行批处理:

call "%VS150COMNTOOLS%VsDevCmd.bat"
MSBuild DailyBuild.proj /t:DailyBuild /p:VersionNumber=%2 /l:FileLogger,Microsoft.Build.Engine;logfile=Build.log
Run Code Online (Sandbox Code Playgroud)

DailyBuild.proj 文件如下所示:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <SourcesPath>$(MSBuildProjectDirectory)\..\..\</SourcesPath>
    <CSCleanProperties>BuildType=Clean;Configuration=Release;IsFormalBuild=true</CSCleanProperties>
    <CSBuildProperties>BuildType=ReBuild;Configuration=Release;PauseBuildOnError=false;PublishWebSites=true;VersionName=myProd-$(VersionNumber)</CSBuildProperties>
  </PropertyGroup>

  <Target Name="DailyBuildWithClean">
    <MSBuild Projects="$(MSBuildProjectDirectory)\Make.proj" Targets="Clean" Properties="$(CSCleanProperties)"/>
    <MSBuild Projects="$(MSBuildProjectDirectory)\Make.proj" Properties="$(CSCleanProperties)"/>
    <MSBuild Projects="$(MSBuildProjectDirectory)\Make.proj" Targets="FormalBuild" Properties="$(CSBuildProperties)"/>
  </Target>

  <Target Name="DailyBuild">
    <MSBuild Projects="$(MSBuildProjectDirectory)\Make.proj" Targets="SW;PreparePackFolder" Properties="$(CSBuildProperties)"/>
  </Target>

</Project>
Run Code Online (Sandbox Code Playgroud)

Make.proj 是一个 proj 文件,其中包含要构建的许多应用程序的定义,其中之一是我的 ASP.NET Core 应用程序。

我该如何解决这个问题?谢谢你。

解决方案编辑:感谢 Martin Ullrich 的解决方案:

在 DailyBuild.proj 中添加了目标 Restore,还在 …

c# msbuild asp.net-core

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

在 ASP.NET Core 中使用 DbContext 注入并行 EF Core 查询

我编写了一个 ASP.NET Core Web 应用程序,它需要我数据库中某些表中的所有数据,以便稍后将其组织成可读格式以进行某些分析。

我的问题是这些数据可能非常庞大,因此为了提高性能,我决定并行获取这些数据,而不是一次获取一张表。

我的问题是我不太明白如何通过继承依赖注入来实现这一点,因为为了能够进行并行工作,我需要DbContext为每个并行工作实例化。

以下代码产生此异常:

---> (Inner Exception #6) System.ObjectDisposedException: Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency …
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection entity-framework-core asp.net-core

5
推荐指数
2
解决办法
3487
查看次数

Azure Cosmos MongoDB - 使用分片键创建集合

我需要在 Azure 的 Cosmos MongoDB 中创建一个集合,但使用分区/分片键,因为所需的配置是数据库将具有预配置的吞吐量(一定量的 RU),并且其中的集合将具有共享吞吐量。

集群的 API 设置为Cosmos DB Mongo API- 如果我在 cosmos 中创建集合,则插入/删除没有任何问题,但如果我使用下面的代码创建集合,我会收到一条错误消息,指出{"Command insert failed: document does not contain shard key."}即使查看在门户中创建的集合,在代码中看起来相同。

client.CreateDocumentCollectionAsync(database.SelfLink,
new DocumentCollection
{
    Id = "CollectionName",
    PartitionKey = new PartitionKeyDefinition { Paths = new Collection<string> { "/_id" } }
}).Wait();
Run Code Online (Sandbox Code Playgroud)

我已经与微软代表交谈过,但我缺乏“答案”。他建议使用Mongo CSharp Driver,但似乎该驱动程序无法定义分区键(这是有道理的)。

如何使用分区键创建集合?

谢谢。

c# azure-cosmosdb azure-cosmosdb-mongoapi

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