Open Closed

Project XXX.Application is not compatible with netstandard2.0 error (Static C# API Client Proxies) #4553


User avatar
0
ademaygun created
  • ABP Framework version: v5.2.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Compile time error:
  • Error NU1201 Project XXX.Application is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project
  • Steps to reproduce the issue:"

According to this link I try to add following lines in ConfigureServices method.

public class MyClientAppModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        // Prepare for static client proxy generation
        context.Services.AddStaticHttpClientProxies(
            typeof(MyClientAppModule).Assembly
        );
    }
}

and add Project References MyApplicationService project into MyApplication.Http.Client projects

But I got compile error: Error NU1201 Project XXX.Application is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project

.Application TargetFramework : .net6.0 .Client TargetFramework : netstandard2.0


21 Answer(s)
  • User Avatar
    0
    ademaygun created

    I guess it should be like this: (document is misspelled)

    typeof(MyClientAppContractsModule).Assembly

    instead of

    typeof(MyClientAppModule).Assembly

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    With Contracts generate all the classes/enums/other types in the client side (including application service interfaces) , This is also the default behavior of the generate-proxy command.

    There is no problem and the MyClientapp should add project references Application and MyApplication.Http.Client. it will generate all needed classes(Dtos, Interfaces, Proxies)

  • User Avatar
    0
    ademaygun created

    I run this command :

    abp generate-proxy -t csharp -u https://localhost:44382/

    output:

    [10:15:13 INF] ABP CLI (https://abp.io)
    [10:15:14 INF] Version 5.3.3 (Stable)
    [10:15:15 WRN] ABP CLI has a newer stable version 7.0.1, please update to get the latest features and fixes.
    [10:15:15 WRN]
    [10:15:15 WRN] Update Command:
    [10:15:15 WRN] dotnet tool update -g Volo.Abp.Cli
    [10:15:15 WRN]
    [10:15:20 INF] Create ClientProxies\ServicePurchaseClientProxy.cs
    [10:15:20 INF] Create ClientProxies\ServicePurchaseClientProxy.Generated.cs
    

    Only created ClientProxy.cs and ServicePurchaseClientProxy.Generated.cs files. Did not create dtos, interfaces etc. and also didn't give any error or warning. Project not build after proxy generation because of missing interfaces and dtos.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This feature is available from 7.0: https://github.com/abpframework/abp/issues/13613

  • User Avatar
    0
    ademaygun created

    I got error:

    [11:17:24 INF] ABP CLI 7.0.1
    [11:17:26 INF] Create ClientProxies\Ekol\FFE\MP\Application\ServicePurchases\ServicePurchaseClientProxy.Generated.cs
    [11:17:26 ERR] Object reference not set to an instance of an object.
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateClassFileAsync(GenerateProxyArgs args, ControllerApiDescriptionModel controllerApiDescription) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 243
       at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 143
       at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\ProxyCommandBase.cs:line 57
       at Volo.Abp.Cli.CliService.RunInternalAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 168
       at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 76
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You should make sure the project version and ABP CLI are the same.

    Because your project version is v5.2.1. Without Contracts is suited for you.

  • User Avatar
    0
    ademaygun created

    I reproduced in v7.0.1 ((server and client)) but I got this output

    [14:47:11 INF] ABP CLI 7.0.1
    [14:47:48 ERR] Response status code does not indicate success: 500 (Internal Server Error).
    System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
       at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
       at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
       at Volo.Abp.Cli.ServiceProxying.ServiceProxyGeneratorBase`1.GetApplicationApiDescriptionModelAsync(GenerateProxyArgs args, ApplicationApiDescriptionModelRequestDto requestDto) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\ServiceProxyGeneratorBase.cs:line 37
       at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 135
       at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\ProxyCommandBase.cs:line 57
       at Volo.Abp.Cli.CliService.RunInternalAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 168
       at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 76
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share the full steps to reproduce? I will check it out. thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).

    Could you share the error logs too? (server)

  • User Avatar
    0
    ademaygun created
    1. Create a new solution via Abp Suite (SampleA)
    2. Create new Entity (Book) via Abp Suite (suite creates Entity,Dtos, ApplicationService) and run it.
    3. Create a second new solution via Abp Suite (SampleB)
    4. Create proxy with contracts:(on SampleB)

    Open a command-line terminal in the root folder of your client project (.csproj) and type the following command: With Contracts abp generate-proxy -t csharp -u http://localhost:53929/(SampleA project API url)

    Note: I haven't run the SampleB project yet because I'm in the proxy generate phase. so no error logs is generated.

    I got this error (command line error):

    [14:47:48 ERR] Response status code does not indicate success: 500 (Internal Server Error).
    System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
       at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
       at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
       at Volo.Abp.Cli.ServiceProxying.ServiceProxyGeneratorBase`1.GetApplicationApiDescriptionModelAsync(GenerateProxyArgs args, ApplicationApiDescriptionModelRequestDto requestDto) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\ServiceProxyGeneratorBase.cs:line 37
       at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 135
       at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\ProxyCommandBase.cs:line 57
       at Volo.Abp.Cli.CliService.RunInternalAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 168
       at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 76
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I could not reproduce the problem as the steps:

    I got this error (command line error):

    Could you share the SampleA error logs ?(not command line error)

  • User Avatar
    0
    ademaygun created

    I sent mail (liangshiwei@abp.io)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    My email is shiwei.liang@volosoft.com

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You need to run the AuthServer(https://localhost:44361).

  • User Avatar
    0
    ademaygun created

    I am sorry. I run AuthServer. But only 3 files generated.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    it's weird, can you share the abp-sample-projects with me? I will check it out. thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I used the project your provided and it's working for me.

    You should make RemoteService to true.

  • User Avatar
    0
    ademaygun created

    It worked successfully when RemoteService(IsEnabled = true) . Thanks. Well,can't proxy classes be used in domain layer? For example I would like to use it in a manager class. I know that I need to move these classes(contracts and interfaces) to the domain in order to use them in the domain layer.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try it, but we don't recommend you to do this

  • User Avatar
    0
    ademaygun created

    Hi, I need to call a remote service in a bg-job,How can I do that?

    could you give more detail. thanks.

    but we don't recommend you to do this

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You just need to inject the service in the job

    could you give more detail. thanks.

    Because the remote service actually is the application layer, The domain layer should not reference the application layer.

    Better to use repositories instead of remote services in domain services, but it's a new topic.

    I think the main problem has been solved, so I close this.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09