小编Soh*_*deh的帖子

未捕获(承诺):在Ionic 2中的cordova_not_available

当我运行离子应用程序时ionic serve -l,得到此错误:

运行时错误

未捕获(承诺):cordova_not_available

Error: Uncaught (in promise): cordova_not_available
at v (http://localhost:8100/build/polyfills.js:3:4864)
at s (http://localhost:8100/build/polyfills.js:3:4289)
at s (http://localhost:8100/build/polyfills.js:3:4112)
at http://localhost:8100/build/polyfills.js:3:4652
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:10284)
at Object.onInvokeTask (http://localhost:8100/build/main.js:38692:37)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:10220)
at e.runTask (http://localhost:8100/build/polyfills.js:3:7637)
at i (http://localhost:8100/build/polyfills.js:3:3707)
at HTMLDocument.invoke (http://localhost:8100/build/polyfills.js:3:11437)
Run Code Online (Sandbox Code Playgroud)

其他详情

Ionic Framework: 2.2.0
Ionic Native: 2.8.1
Ionic App Scripts: 1.1.4
Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 6.9.2
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like …
Run Code Online (Sandbox Code Playgroud)

cordova typescript ionic-framework ionic2 angular

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

使用ProjectTo()时,Mapper未初始化

我在我的项目中使用Automapper 5.2.0.当我ProjectTo()在代码中使用时获取此错误:

Mapper未初始化.使用适当的配置调用Initialize.如果您正试图通过容器或以其它方式使用映射器实例,请确保您不必静态Mapper.Map方法的任何电话,如果你使用ProjectTo或UseAsDataSource扩展方法,确保你在适当的IConfigurationProvider通实例.

服务代码

 public async Task<FreelancerProfileViewModel> GetFreelancerProfile()
    {
        var id = Guid.Parse(_identity.GetUserId());
        var model = await _freelancerProfiles
            .AsNoTracking()
            .Where(_ => _.User.Id == id)
            .ProjectTo<FreelancerProfileViewModel>()
            .FirstAsync();

     //  var viewmodel =  _mapper.Map<FreelancerProfileViewModel>(model);

        return model;
    }
Run Code Online (Sandbox Code Playgroud)

自动映射配置文件

   public class FreelancerDashbordProfile : Profile
{
    private readonly IIdentity _identity;
    public FreelancerDashbordProfile(IIdentity identity)
    {
        _identity = identity;
        var id = Guid.Parse(_identity.GetUserId());
        CreateMap<FreelancerProfile, FreelancerProfileViewModel>()
        .ForMember(_ => _.DoingProjectCount,
            __ => __.MapFrom(_ => _.Projects.Count(project => project.ProjectState == ProjectState.Doing)))

        .ForMember(_ => _.EndProjectCount,
            __ => __.MapFrom(_ …
Run Code Online (Sandbox Code Playgroud)

c# structuremap ioc-container automapper-5

18
推荐指数
2
解决办法
8226
查看次数

为POST Web API使用可选的复杂类型操作参数

我正在尝试使用以下原型编写API:

[HttpPost]
public ApplicationStatus appLogIn(string id, UserCredentials userCredentials = null)
Run Code Online (Sandbox Code Playgroud)

但是当我向这个API提出请求时,无论有没有userCredentials,我都会得到以下错误,响应代码为500

{
  "Message": "An error has occurred.",
  "ExceptionMessage": "Optional parameter 'userCredentials' is not supported by 'FormatterParameterBinding'.",
  "ExceptionType": "System.InvalidOperationException",
  "StackTrace": null
}
Run Code Online (Sandbox Code Playgroud)

如果我不将userCredentials作为可选项,一切正常.userCredential定义如下:

public class UserCredentials
{
    public string password { get; set; }
    public string username { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

asp.net http-post restful-architecture asp.net-web-api

10
推荐指数
1
解决办法
3441
查看次数

如何将角度材料2方向更改为RTL

我想用Angular材料创建RTL模板2但是,我不知道如何做这项工作?请帮我;

right-to-left angular-material2 angular

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

将.NET核心应用程序发布为可移植可执行文件

我有一个简单的.net核心应用程序,并通过以下命令发布它:

 dotnet publish -c Release -r win10-x64
Run Code Online (Sandbox Code Playgroud)

SqlLocalDbStarter.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
  </ItemGroup>

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

当发布过程完成dotnet win10-x64bin\Release文件夹中创建文件夹然后打开后,该文件夹包含publish文件夹和一些dll和exe文件.

对我来说有一些问题:

  • exe我需要PE应用程序中的哪一个文件(内部/外部发布文件夹)?
  • 为什么当我剪切exe文件并将其移动到其他地方时它不会运行(没有消息)?
  • 如果我需要所有dll文件来运行应用程序,那么我有两个选项(内部/外部发布文件夹),内部发布文件夹大小为66 MB但外部发布文件夹为1 MB.
  • 我想有一个exe文件来运行我的程序没有DLL文件.

文件夹大小图像

.Net信息

c# publish self-contained portable-executable .net-core

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

bootstrap 4中的自定义输入文件不显示按钮

当我在bootstrap 4中使用自定义输入文件时,请勿更改我的输入并且不显示browse按钮.

文件浏览器

<label class="custom-file">
    <input type="file" id="Image" class="custom-file-input">
    <span class="custom-file-control"></span>
</label>
Run Code Online (Sandbox Code Playgroud)

.custom文件

position: relative;
display: inline-block;
max-width: 100%;
height: 2.5rem;
cursor: pointer;
Run Code Online (Sandbox Code Playgroud)

.custom文件输入

min-width: 14rem;
max-width: 100%;
margin: 0;
filter: alpha(opacity=0);
opacity: 0;
Run Code Online (Sandbox Code Playgroud)

.custom文件控制

position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 5;
height: 2.5rem;
padding: .5rem 1rem;
line-height: 1.5;
color: #555;
user-select: none;
background-color: #fff;
border: 1px solid #ddd;
border-radius: .25rem;
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

html css twitter-bootstrap twitter-bootstrap-4 bootstrap-4

7
推荐指数
2
解决办法
9383
查看次数

未捕获的TypeError:element.removeClass不是Jquery中的函数

我使用此示例验证我的表单,但出现此错误:

未捕获的TypeError:element.removeClass不是函数 说removeClass()不是函数!! 我糊涂了

我的Js代码:

$(function () {
            var form = $('#CompanyStep')
              , formData = $.data(form[0])
              , settings = formData.validator.settings
              , oldErrorPlacement = settings.errorPlacement
              , oldSuccess = settings.success;

            settings.errorPlacement = function (label, element) {

                debugger;
                oldErrorPlacement(label, element);

                label.parents('.form-group').addClass('has-danger');
                label.addClass('text-danger');
                element.addClass('form-control-danger');
            };

            settings.success = function (label, element) {

                debugger;

                label.parents('.form-group').removeClass('has-danger');
                label.parents('.form-group').addClass('has-success');
                element.removeClass('form-control-danger');
                element.addClass('form-control-success');


                oldSuccess(label, element);
            };
        });
Run Code Online (Sandbox Code Playgroud)

javascript jquery function removeclass

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

Dotnet 发布在 Debug 目录而不是 Release 中查找依赖项

我有一个Project.Api引用另一个项目的项目Project.DomainModel。当我通过运行构建要发布的 API 项目时

dotnet restore && dotnet build -c Release
Run Code Online (Sandbox Code Playgroud)

它构建成功。但是,当我尝试发布时

 dotnet publish -c Release -o published --no-restore --no-build ./Project.Api
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

/usr/local/share/dotnet/sdk/2.1.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(168,5): error MSB3030: Could not copy the file "xxxx/Project.DomainModels/bin/Debug/netcoreapp2.1/Project.DomainModels.dll" because it was not found. [xxxx/Project.Api/Project.Api.csproj]
Run Code Online (Sandbox Code Playgroud)

根据错误,它正在Debug目录中寻找引用的项目,但当然它不会在那里找到它,因为它会在Release目录中。

Project.Api.csproj 文件如下所示:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="8.0.0" />
  </ItemGroup>
  <ItemGroup>
      <ProjectReference Include="..\Project.DomainModels\Project.DomainModels.csproj" />
  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

知道为什么它在 Debug 目录而不是 Release 中查找吗?在 Mac 和 linux 机器上都得到这个。

c# asp.net-core dotnet-publish

6
推荐指数
2
解决办法
1901
查看次数

在ajax请求中发送带有JSON数据的文件

我想将图像文件发送到控制器,但该文件HttpPostedFileBase为空,我进入image: image外部 JSON.stringify({})但不起作用。另外,我改变contentType并看到这个问题并使用它的答案,但我的问题没有解决。

var file_data = $("#Image").prop("files")[0];   
var image = new FormData();

image.append("file", file_data);

$.ajax({
        url: '@postUrl',
        method: "POST",
        contentType: 'application/json',
        data:
            JSON.stringify({
                    image: image,
                    isFirst : true,
                    ExternalProjects: ExternalProjects,
                    // more data

            })
       })
Run Code Online (Sandbox Code Playgroud)

javascript ajax asp.net-mvc jquery

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

在Identity中获取当前用户的电子邮件

我使用IIdentity接口获取当前useridusername.

所以实现以下方法:

private static IIdentity GetIdentity()
{
    if (HttpContext.Current != null && HttpContext.Current.User != null)
    {
        return HttpContext.Current.User.Identity;
    }

    return ClaimsPrincipal.Current != null ? ClaimsPrincipal.Current.Identity : null;
}
Run Code Online (Sandbox Code Playgroud)

并添加以下代码:_.For<IIdentity>().Use(() => GetIdentity());我的IoC容器[structuremap].

用法

this._identity.GetUserId();
this._identity.GetUserName();
this._identity.IsAuthenticated
Run Code Online (Sandbox Code Playgroud)

现在我想实施GetEmailAdress方法,如何做到这一点?

this._identity.GetEmailAdress();
Run Code Online (Sandbox Code Playgroud)

使用时this._identity.GetUserName();不要获取用户名表格数据库.

c# asp.net-mvc identity

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