Tag: .net

.NET核心getstringasync在Docker中不起作用

我试图通过下载JSON并在列表中显示它来创build一个显示我的Elasticsearch快照信息的小型Web应用程序。 IP是我的本地主机,我也运行一个3个节点的elasticsearch集群。 如果我尝试在泊坞窗中运行它,它将等待100秒,超时没有检索到数据,但没有docker工程。 我没有得到任何错误,只是超时,并继续。 public async Task<IActionResult> Index() { using (var httpClient = new HttpClient()) { var elasticpass = "elastic:changeme"; var byteArray = new UTF8Encoding().GetBytes(elasticpass); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); var json = await httpClient.GetStringAsync("http://192.168.1.50:9200/_snapshot/mainrepo/_all"); var model = Newtonsoft.Json.JsonConvert.DeserializeObject<Rootobject>(json); var snapshotList = model.snapshots.ToList(); var myList = snapshotList.OrderByDescending(x => x.start_time); model.SnapShotList = myList; foreach (var item […]

无法在Docker上运行VS项目

首先,我正在学习如何从命令行使用Docker。 然后,想看看我能用Visual Studio做什么。 我的目标是使用Visual Studio 2017创buildASP.NET Core Web API,并使用容器开发,debugging,testing和部署该Web API。 该解决scheme有两个项目:一个是通常的ASP.NET Core项目,另一个是Docker Compose: 正如你所看到的,它和你在任何其他ASP.NET Core应用程序中看到的是相同的Program.cs和Startup.cs,这是相同types的控制器,所以C#代码中什么都不知道Docker或容器或者将要进入的运营环境。 Docker与这个特定项目相关的唯一的事情就是Docker文件的存在(你可以看到它在图像中打开,并带有build立另一个图像的说明)。 特定的图像将成为一个Linux映像。 所以,我需要做的一件事就是进入Docker菜单并切换到Linux容器: 重现问题的步骤 启动VS2017 创build一个新的项目,C#,ASP.NET核心Web应用程序(启用Docker支持) 使用Docker运行和debugging(F5) 预期的行为 应用程序运行并允许其debugging。 实际行为 由于错误,构build失败: 1>—— Build started: Project: docker-compose, Configuration: Debug Any CPU —— 1>docker-compose -f "C:\Users\tiagoperes\Documents\Visual Studio 2017\Projects\PsWebApi\docker-compose.yml" -f "C:\Users\tiagoperes\Documents\Visual Studio 2017\Projects\PsWebApi\docker-compose.override.yml" -f "C:\Users\tiagoperes\Documents\Visual Studio 2017\Projects\PsWebApi\docker-compose.vs.debug.yml" -p dockercompose1712142422 config 1>services: 1> pswebapi: […]

缺less相同版本的框架上的命名空间

我有两个相同的基于.net核心的应用程序。 首先是在docker集装箱,我有1.0.4版本的.net核心。 其次是在我的虚拟机Ubuntu 16.0.4,我也有.net核心的1.0.4版本。 问题是,当我想要在基于Docker容器的应用程序上使用声明时,找不到声明名称空间,但是在Ubuntu虚拟机上,一切正常。 这是为什么? 这两个应用程序使用相同的.net核心框架,所以为什么我不能find我的docker集装箱上的声明命名空间? 这可能听起来很奇怪,但是,我有3个解决scheme,第一个解决scheme声明命名空间是可用的,但其余的doestn't 有csproj文件。 <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="AutoMapper" Version="6.1.1" /> <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Evento.Infrastructure\Evento.Infrastructure.csproj" /> </ItemGroup> </Project> 第二 <Project Sdk="Microsoft.NET.Sdk"> <ItemGroup> <ProjectReference Include="..\Evento.Core\Evento.Core.csproj" /> </ItemGroup> […]

在Windows中为Docker创build镜像文件正被另一个进程使用错误

我在这个video上尝试了一个新的.net项目。 当我在shell中尝试这个: docker image build –tag myusername/sample0726 . 它显示了所有的酒吧,看起来像是在做什么,但最终它给了我这个错误: 无法注册图层:重新执行错误:进程无法访问文件,因为它正在被另一个进程使用。 我正在使用VS 2017,Docker for windows,如果有人知道一个好的.net示例项目使用Windows容器请让我知道。

在VS 2017中构build和部署远程主机上的docker容器

VS 2017有一个Docker支持,允许在本地机器上从VS构build和运行docker容器。 是否有可能在远程Linux机器上build立和运行容器? 我find了这个文档 ,但是已经过时了。

无法使用docker运行dotnet核心预览2项目

我无法在dotnet core preview 2上的windows server 2016上运行docker容器。我能够构build到docker容器,但在运行期间,我收到以下错误。 Creating network "dockercompose_default" with the default driver Creating dockercompose_flousermanagement_1 … Creating dockercompose_flousermanagement_1 … done Attaching to dockercompose_flousermanagement_1 flousermanagement_1 | The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview2-25407-01' was not found. flousermanagement_1 | – Check application dependencies and target a framework version installed at: flousermanagement_1 | C:\Program Files\dotnet\shared\Microsoft.NETCore.App flousermanagement_1 | – The […]

支持Docker的ASP.NET Core:拒绝连接

我有一个支持Docker的ASP .NET Core(v2.0)应用程序。 我想在启动我的应用程序时启动一个Oracle数据库。 这是我的docker-compose文件的样子: version: '3' services: devarttestapp: image: devarttestapp build: context: ./DevartTestApp dockerfile: Dockerfile oracledb: image: sath89/oracle-12c ports: – "1521:1521" 我使用Devart数据提供程序dotConnect for Oracle。 var conn = new Devart.Data.Oracle.OracleConnection(); conn.ConnectionString = Environment.GetEnvironmentVariable("ORACLE_CONNECTION_STRING"); try { conn.Open(); } catch (Exception e) { Console.WriteLine(e); throw; } 但是,当我尝试连接到创build的Oracle数据库容器的数据库时,我得到以下exception: System.Net.Internals.SocketExceptionFactory + ExtendedSocketException(连接被拒绝127.0.0.1:1521) 我也尝试在我的docker-compose文件中包含depends_on以及networking选项,并得到相同的结果。 什么可能是这个例外的原因? 我该如何解决这个问题?

在VS 2017中debugging运行docker容器

我怎样才能在Visual Studio 2017中debugging运行docker容器? 我尝试使用远程debugging器按照每个post 。 但是,当我尝试执行命令: docker exec -it <id/name> "C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe" /nostatus /silent /noauth /anyuser /nosecuritywarn , 我收到一个错误: rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"C:\\\\Program Files\\\\Microsoft Visual Studio 15.0\\\\Common7\\\\IDE\\\\Remote Debugger\\\\x64\\\\msvsmon.exe\": executable file not found in $PATH" 试图手动运行debugging器,它启动没有任何问题。 我正在使用VS […]

不能将参数添加到Dockerfile RUN命令

我正在创build一个Dockerfile来构build和部署一个ASP.NET 4应用程序。 我有这个代码: #Use the add-msbuild image that has msbuild.exe installed. This image inherits from microsoft/iis. FROM add-msbuild #Make a folder in the container that will contain the application. RUN mkdir "C:\site" RUN mkdir "C:\site\packages" RUN mkdir "C:\build" #Copy the application source code to the build folder. COPY . "C:\build" WORKDIR "C:\build" #Build the application. […]

在Visual Studio 2017中添加Docker支持缺less

我在我的电脑上安装了Visual Studio Community 2017(v。15.3.4),Docker for Windows CE(稳定通道,v。17.06.2-ce-win27(13194))和.NET Core SDK 2.0.0。 此外,我启用了Windowsfunction,称为容器和检查Visual Studio安装程序容器支持。 首先我启动Docker for Windows(Linux Containers),然后启动Visual Studio。 我去文件 – >新build – >项目 – >安装/ Visual C#/ Web – > ASP.NET核心Web应用程序,然后点击确定。 我找不到添加Docker支持的选项? 同样是如果我创build项目,右键单击项目,上下文菜单不给我这个选项。 我错过了什么?