Hello, I have solved it while i am preparing a minimal project :) Sometimes it is better to create it from scratch. Here is my findings and some questions if you can answer. I can also send the sample test project if you do not understand the questions just let me know.
So my problem was with the namespace. When i expose my services from the module i create "Controller" folder under httpapi project then set all folders under it here is a screenshot from my folder structure.
so i was trying to inject the isampleappservice from the application service namespace instead of controller namespace. And static generation is creating the isampleappservice for the controller namespace.
So the first question is if do not put my controller class under controller folder and namespace, it becomes ambiguous namespace for isampleappservice. Cause it is gonna be two isampleappservice comes from application.contracts and from generated folder. How can you fix that? Second question is about "With Contracts and Without Contracts" (https://docs.abp.io/en/abp/latest/API/Static-CSharp-API-Clients#client-proxy-generation) if i create my proxies without contracts first problem is solved. But i want to know downsides of it. Why isampleappservice is created at the first place with contracts? isn't the project referencing to application.contracts anyway? when you create your proxies "with contracts" then shouldn't you reference to application.contracts project? if you do not reference it, as i see it, it doesn't generate the dtos? how it is gonna be functional then?
As you can see i am little bit confused how should it be used. I want to create a nuget package that can be shared on my private repository since different ui platforms needs to access the backend. Any advice to do that? with or without contracts?
one more thing about the problem. My HttpApi Client module consists of multiple HttpApi Client modules. After i posted the previous message, i have tried with only one of them, then the exception go away, but this time i got another exception message. "no service for type IScreenAppService has been registered". So somehow it can not get the service from ioc container. But i can see the generated service. I couldn't understand what i am doing wrong.
Hello i changed the client module to static api but i am getting the same error. And the exception is the same. Do i do sth wrong over here? Is there any specific config that i need to do? To state the app that i use static proxies? Here is an overview of what i have done.
you can see the folder structure here for static proxies.
here is the client module code.
using Doohlink.CampaignManagement;
using Doohlink.ClientManagement;
using Doohlink.CreativeManagement;
using Doohlink.FtpServerManagement;
using Doohlink.InventoryManagement;
using Doohlink.OccupancyManagement;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account;
using Volo.Abp.AuditLogging;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Gdpr;
using Volo.Abp.Identity;
using Volo.Abp.LanguageManagement;
using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict;
using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement;
using Volo.Abp.TextTemplateManagement;
using Volo.Abp.VirtualFileSystem;
using Volo.Saas.Host;
using Doohlink.MagicInfo;
using Volo.Payment;
using Volo.Payment.Admin;
using Doohlink.AdzupPlayerManagement;
namespace Doohlink;
[DependsOn(
typeof(DoohlinkApplicationContractsModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule),
typeof(AbpFeatureManagementHttpApiClientModule),
typeof(AbpSettingManagementHttpApiClientModule),
typeof(SaasHostHttpApiClientModule),
typeof(AbpAuditLoggingHttpApiClientModule),
typeof(AbpOpenIddictProHttpApiClientModule),
typeof(AbpAccountAdminHttpApiClientModule),
typeof(AbpAccountPublicHttpApiClientModule),
typeof(LanguageManagementHttpApiClientModule),
typeof(AbpGdprHttpApiClientModule),
typeof(TextTemplateManagementHttpApiClientModule)
)]
[DependsOn(typeof(CreativeManagementHttpApiClientModule))]
[DependsOn(typeof(CampaignManagementHttpApiClientModule))]
[DependsOn(typeof(InventoryManagementHttpApiClientModule))]
[DependsOn(typeof(ClientManagementHttpApiClientModule))]
[DependsOn(typeof(OccupancyManagementHttpApiClientModule))]
[DependsOn(typeof(FtpServerManagementHttpApiClientModule))]
[DependsOn(typeof(MagicInfoHttpApiClientModule))]
[DependsOn(typeof(AbpPaymentHttpApiClientModule))]
[DependsOn(typeof(AbpPaymentAdminHttpApiClientModule))]
[DependsOn(typeof(AdzupPlayerManagementHttpApiClientModule))]
public class DoohlinkHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddStaticHttpClientProxies(
typeof(DoohlinkApplicationContractsModule).Assembly,
RemoteServiceName
);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<DoohlinkHttpApiClientModule>();
});
}
}
and here how it is implemented on avalonia ui.
using Adzup.Player.Services;
using Adzup.Player.Utils;
using Doohlink;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
namespace Adzup.Player;
[DependsOn(
typeof(AdzupPlayerUtilsModule),
typeof(DoohlinkHttpApiClientModule))]
public class AdzupPlayerModule:AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
#if DEBUG
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientBuildActions.Add((_, clientBuilder) =>
{
clientBuilder.ConfigurePrimaryHttpMessageHandler(HttpClientHelper.GetInsecureHandler);
});
});
#endif
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration=context.Services.GetConfiguration();
Configure<PlayerOptions>(configuration.GetSection(PlayerOptions.Player));
}
}
and here how abp is initialized for avalonia.
using System.IO;
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Serilog;
using Serilog.Events;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace Adzup.Player;
public static class AbpBootstrapper
{
public static IAbpApplicationWithInternalServiceProvider? AbpApplication { get; private set; }
public static bool IsInitialized => AbpApplication != null;
public static void InitializeIfNeeds<T>()
where T : AbpModule
{
if (IsInitialized)
{
return;
}
AbpApplication = CreateAbpApplication<T>().ConfigureInstallationId();
AbpApplication?.Initialize();
}
private static IAbpApplicationWithInternalServiceProvider? CreateAbpApplication<T>() where T : AbpModule
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
#if DEBUG
.MinimumLevel.Override("AbpWithAvalonia", LogEventLevel.Debug)
#else
.MinimumLevel.Override("AbpWithAvalonia", LogEventLevel.Information)
#endif
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
var assembly = typeof(App).GetTypeInfo().Assembly;
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
#if DEBUG
.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.debug.json", optional: true, false)
#else
.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.json", optional: true, false)
#endif
.Build();
var application = AbpApplicationFactory.Create<T>(options =>
{
options.Services.ReplaceConfiguration(configuration);
// options.UseAutofac();
options.Services.AddLogging(c => c.AddSerilog());
});
return application;
}
public static T? GetRequiredService<T>() where T : class
{
return AbpApplication?.Services.GetRequiredService<T>();
}
public static void ShutDown()
{
AbpApplication?.ShutdownAsync().GetAwaiter().GetResult();
AbpApplication?.Dispose();
AbpApplication = null;
}
}
and i have this exception again when i try to resolve the appservice.
System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
at System.Reflection.Emit.AssemblyBuilder.ThrowDynamicCodeNotSupported()
at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
at System.Reflection.Emit.RuntimeAssemblyBuilder..ctor(AssemblyName n, AssemblyBuilderAccess access)
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access)
at Castle.DynamicProxy.ModuleScope.CreateModule(Boolean signStrongName)
at Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithWeakName()
at Castle.DynamicProxy.ModuleScope.ObtainDynamicModule(Boolean isStrongNamed)
at Castle.DynamicProxy.ModuleScope.DefineType(Boolean inSignedModulePreferably, String name, TypeAttributes flags)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateTypeBuilder(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces, TypeAttributes flags, Boolean forceUnsigned)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces, TypeAttributes flags, Boolean forceUnsigned)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildClassEmitter(String typeName, Type parentType, IEnumerable`1 interfaces)
at Castle.DynamicProxy.Generators.BaseInterfaceProxyGenerator.Init(String typeName, ClassEmitter& emitter, Type proxyTargetType, FieldReference& interceptorsField, IEnumerable`1 allInterfaces)
at Castle.DynamicProxy.Generators.BaseInterfaceProxyGenerator.GenerateType(String typeName, INamingScope namingScope)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.<>c__DisplayClass13_0.<GetProxyType>b__0(CacheKey cacheKey)
at Castle.Core.Internal.SynchronizedDictionary`2[[Castle.DynamicProxy.Generators.CacheKey, Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc],[System.Type, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(CacheKey key, Func`2 valueFactory)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.GetProxyType()
at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor[] interceptors)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionHttpClientProxyExtensions.<>c__DisplayClass4_0.<AddHttpClientProxy>b__1(IServiceProvider serviceProvider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IScreenAppService](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionCommonExtensions.GetRequiredService[IScreenAppService](IServiceCollection services)
at Adzup.Player.AbpBootstrapper.GetRequiredService[IScreenAppService]()
at Adzup.Player.ViewModels.ConfigurationViewModel..ctor() in /Users/cangunaydin/projects/Adzup.Player/Adzup.Player/Adzup.Player/ViewModels/ConfigurationViewModel.cs:line 36
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
at System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Extensions.DependencyInjection.ServiceProvider.ServiceAccessor, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].GetOrAdd(ServiceIdentifier key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Volo.Abp.DependencyInjection.ConventionalRegistrarBase.<>c__DisplayClass10_0.<CreateServiceDescriptor>b__0(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at
appservice is resolve like this in view model.
_screenAppService = AbpBootstrapper.GetRequiredService<IScreenAppService>()!;
hope you can point me into the right direction. thank you.
Hello, The question is related with Abp Client Proxies. I have a web server which uses abp and abp endpoints. Now i want to share the httpclient module of the web server and use it in avalonia ui project. I created an abp module and do necessary configurations for avalonia project. Added HttpClient project reference. Now when i run the project on android environment it works fine. But when i run it on ios, it throws an exception "platform not supported exception". here is the full exception
System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
at System.Reflection.Emit.AssemblyBuilder.ThrowDynamicCodeNotSupported()
at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
at System.Reflection.Emit.RuntimeAssemblyBuilder..ctor(AssemblyName n, AssemblyBuilderAccess access)
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access)
at Castle.DynamicProxy.ModuleScope.CreateModule(Boolean signStrongName)
at Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithWeakName()
at Castle.DynamicProxy.ModuleScope.ObtainDynamicModule(Boolean isStrongNamed)
at Castle.DynamicProxy.ModuleScope.DefineType(Boolean inSignedModulePreferably, String name, TypeAttributes flags)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateTypeBuilder(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces, TypeAttributes flags, Boolean forceUnsigned)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces, TypeAttributes flags, Boolean forceUnsigned)
at Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope moduleScope, String name, Type baseType, IEnumerable`1 interfaces)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildClassEmitter(String typeName, Type parentType, IEnumerable`1 interfaces)
at Castle.DynamicProxy.Generators.BaseInterfaceProxyGenerator.Init(String typeName, ClassEmitter& emitter, Type proxyTargetType, FieldReference& interceptorsField, IEnumerable`1 allInterfaces)
at Castle.DynamicProxy.Generators.BaseInterfaceProxyGenerator.GenerateType(String typeName, INamingScope namingScope)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.<>c__DisplayClass13_0.<GetProxyType>b__0(CacheKey cacheKey)
at Castle.Core.Internal.SynchronizedDictionary`2[[Castle.DynamicProxy.Generators.CacheKey, Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc],[System.Type, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(CacheKey key, Func`2 valueFactory)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.GetProxyType()
at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor[] interceptors)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionHttpClientProxyExtensions.<>c__DisplayClass4_0.<AddHttpClientProxy>b__1(IServiceProvider serviceProvider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IScreenAppService](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionCommonExtensions.GetRequiredService[IScreenAppService](IServiceCollection services)
at Adzup.Player.AbpBootstrapper.GetRequiredService[IScreenAppService]()
at Adzup.Player.ViewModels.ConfigurationViewModel..ctor() in /Users/cangunaydin/projects/Adzup.Player/Adzup.Player/Adzup.Player/ViewModels/ConfigurationViewModel.cs:line 36
so the reason is obvious from the stacktrace. According to microsoft docs for ios, it says:
Since the iOS kernel prevents an application from generating code dynamically, Xamarin.iOS does not support any form of dynamic code generation. These include:
The System.Reflection.Emit is not available.
No support for System.Runtime.Remoting.
No support for creating types dynamically (no Type.GetType ("MyType`1")), although looking up existing types (Type.GetType ("System.String") for example, works just fine).
Reverse callbacks must be registered with the runtime at compile time.
I also find a previous post related with this https://support.abp.io/QA/Questions/2752/SystemPlatformNotSupportedException-when-running-Xamarin-Forms-on-iOS-using-ABP-Module-with-Autofac
so the question is, is it possible to make this work so i can use the httpclient module for my avalonia ios project? And I wonder how does this work for Maui App if it does not support System.Reflection.Emit. It seems like Castle.DynamicProxy class calls System.Reflection.Emit. Is Maui project bypassing this by replacing the service with sth else?
Hello, Thanks for the solution. I wonder two things.
Also if i want to intercept the http requests, what is the correct way to do it in Maui Project? Let's say i want to add extra header for specific request. I tried sth like this but this doesn't work.
[Volo.Abp.DependencyInjection.Dependency(ReplaceServices = true)]
[ExposeServices(typeof(DynamicHttpProxyInterceptorClientProxy<IIdentityUserAppService>))]
public class IdentityUserAppServiceHttpProxyInterceptorClientProxy : DynamicHttpProxyInterceptorClientProxy<IIdentityUserAppService>
{
protected override void AddHeaders(IReadOnlyDictionary<string, object> argumentsDictionary, ActionApiDescriptionModel action,
HttpRequestMessage requestMessage, ApiVersionInfo apiVersion)
{
base.AddHeaders(argumentsDictionary, action, requestMessage, apiVersion);
}
protected override Task<HttpContent> RequestAsync(ClientProxyRequestContext requestContext)
{
return base.RequestAsync(requestContext);
}
}
Hello I am having problem with maui application when i do posts to the api. HttpStatusCode:400 returns every time, is sth changed on antiforgery token middleware on version 8?
I didn't have this problem on v7.4.
To reproduce the problem just create a new project from scratch with v8 rc2.
abp new BookStore -t app-pro -u angular -dbms PostgreSQL --separate-auth-server -m maui -csf --preview
then try to run maui app and **create a new user **(or try to do any post or put). you will get an error. Bad Request with status code 400
is there a way to ignore antiforgery token check for mobile app calls only.
Hello again,
I understand why now. i switch to mac, that's why it appears in my solution. Cause $(UserProfile) env variable not exists on mac.
env variable is $(HOME) instead.
I think you should use this instead on common.props file. $([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))
so you can support for each operating system. check this issue. https://github.com/dotnet/msbuild/issues/3908
Hello again, new updates from me. Now i fixed everything that i wanted. It was little struggle though. I will write here what I have done.
<Style TargetType="BoxView" x:Key="InputSeparator"> <Setter Property="Margin" Value="{OnPlatform Android='0,0,0,0',iOS='0,10,0,0',MacCatalyst='0,10,0,0'}"></Setter> <Setter Property="HeightRequest" Value="1"> </Setter> <Setter Property="HorizontalOptions" Value="Fill"></Setter> </Style>
<Style TargetType="Label" x:Key="InputLabel">
<Setter Property="Margin" Value="{OnPlatform iOS='0,0,0,5',MacCatalyst='0,0,0,5'}"></Setter>
</Style>
Then i have added those styles to label and entries for form elements. As an example:
as a result i got some border at the end for both android and ios.
async partial void OnIdChanged(string? value)
This was causing threading problems i guess. So probably changing color was not invoked. so what i did instead is use AsyncHelper and leave the method as sync. Here is the code.
partial void OnIdChanged(string? value)
{
IsBusy = true;
AsyncHelper.RunSync(GetTenant);
AsyncHelper.RunSync(GetEditions);
IsBusy = false;
}
i have seen some people are using async void but according to me it is not the best practice.From my experience, it always bring some problems with it. The same problem exists on WeakReferenceMessenger. I have changed the code over there also. So i have been able to get the user interface that i wanted. here is how it looks at the end. Thanks for the code that has been provided by the way, it helped me a lot. On the other hand what i think is, on the long run adding RemovingHandlers to the project can be problematic in some cases. But for now it is good to go.
Hello thanks for the feedback, I have also started to fix the things one by one.
I have also upgraded my app to .net 8 yesterday, some things have been fixed however still some problems persist and some new problems arrived.
I will write over here if i can fix those things that i mention
Also worth to mention, I tried this .net 7, on list pages, maybe it has been fixed on .net 8 i didn't try
<RefreshView Grid.Row="1" IsRefreshing="{Binding IsBusy}" Command="{Binding RefreshCommand}">
this code makes the RefreshCommand triggers on the page load. since page appearing is also triggering the same code you call the endpoint twice. There was a discussion about it also in .net maui github issues. To overcome the situation, what i did was to bind RefreshCommand.IsRunning property instead of IsBusy. The reason behind this issue is when you call RefreshCommand it also sets the IsBusy property to true then it triggers the RefreshCommand again. new code is sth similar like this in my case.
<RefreshView Grid.Row="1" IsRefreshing="{Binding RefreshCommand.IsRunning}" Command="{Binding RefreshCommand}">