Akka with Xamarin Error "Configuration system failed initialize" - c#

Hello I am trying execute a xamarin app and I would like to create an actor, through the actor system of the akka library, but I receive the error “Configuration system failed initialize” just when trying to create the ActorSystem.
private static readonly ActorSystem _system;
public static readonly IActorRef _coordinator;
static CrawlingSystem ()
{
_system = ActorSystem.Create ("crawling-system");
_coordinator = _system.ActorOf (Props.Create <BackupActor> (), "backupactor");
}
The static CreawlingSystem class is called directly by MainPage.Xaml.cs
I am using visual Studio 2019, an empty Xamarin.Forms project, akka 1.4.21, Xamarin.Forms 5.0.0.2012.
Also i tried with versions: akka 1.3.9, Xamarin.Forms 3.3.0912540, but the error persists

Try changing your ActorSystem.Create call to the following:
_system = ActorSystem.Create ("crawling-system", ""); // empty config
This will stop Akka.NET from trying to query against System.Configuration.ConfigurationManager, which is apparently not supported on Xamarin and gets loaded automatically when no default configuration is provided.

Related

Share the app feature implement using dependency service in xamarin forms android project

I am implementing Share the App feature in Xamarin forms project. Yes, there are libraries which are available, But library conflicts with a version of Xamarin forms package and I have already completed all the stuff and don't want any issue, and I want to implement using dependency service by doing platform specific coding in Android and iOS without any package.
Here, I am using intent for share the app from Android project by making custom renderer. But I am getting error.
public class ShareTheAppRenderer : IShareTheApp
{
public void ShareApp()
{
var mainActivity = new MainActivity();
Intent sendIntent = new Intent();
sendIntent.SetAction(Intent.ActionSend);
sendIntent.PutExtra(Intent.ExtraText, "Check out our app at: https://play.google.com/store/apps/details?id=");
sendIntent.SetType("text/plain");
mainActivity.StartActivity(sendIntent);
}
}
Please give some suggestions to resolve this issue.
Thank you for your reply. But I got the solution for this. Here I don't want to use any other libraries to achieve this.
My Working solution is as below:
public class ShareTheAppRenderer : IShareTheApp
{
public void ShareApp()
{
var appPackageName = Forms.Context.PackageName;
var myIntent = new Intent(Android.Content.Intent.ActionSend);
myIntent.SetType("text/plain");
myIntent.PutExtra(Intent.ExtraText, "Check out our app at: https://play.google.com/store/apps/details?id=" + appPackageName);
Forms.Context.StartActivity(Intent.CreateChooser(myIntent, "Choose an App"));
}
}
This solution works for me.

Unity AdMob - ClassNotFound: com.google.unity.ads.UnityAdListener

My app is getting the following error when trying to load or show interstitial ad via AdMob for Unity: ClassNotFoundException: com.google.unity.ads.UnityAdListener.
AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityAdListener
java.lang.ClassNotFoundException: com.google.unity.ads.UnityAdListener
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
at android.os.MessageQueue.next(MessageQueue.java:394)
at android.os.Looper.loop(Looper.java:142)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.unity.ads.UnityAdListener"
My main advertisment code is:
public class AdsTest : MonoBehaviour
{
private InterstitialAd interstitial;
public void LoadAd()
{
string adUnitId = "ca-app-pub-3940256099942544/1033173712";
interstitial = new InterstitialAd(adUnitId);
interstitial.OnAdLoaded += HandleOnAdLoaded;
interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
interstitial.OnAdOpening += HandleOnAdOpened;
interstitial.OnAdClosed += HandleOnAdClosed;
interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication;
AdRequest request = new AdRequest.Builder().Build();
interstitial.LoadAd(request);
}
public void ShowAd()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
...
}
The rest of the AdsTest class are the standard event voids (OnAdLoaded, OnAdClosed, ect.), the same as they're in Google's docs.
Calling the ads script from another class:
void OnTriggerEnter2D(Collider2D trigger)
{
ReturnToStart();
// where ads is a instance of the AdsTest class
// ads = new AdsTest();
ads.LoadAd();
ads.ShowAd();
}
And I've initialized the AdMob Id at the beginning of the game in a controller object.
// executed when the app starts
string appId = "ca-app-pub-3522556458609123~3670809634";
MobileAds.Initialize(appId);
I've imported all the assets from the unity-package and force resolved the play services dependencies.
Also my AndroidManifest looks like this:
Environment and versioning:
Unity - 2018.3.0f2 Personal for Windows 10 x64
Android SDK - 27
AdMob Plugin - v3.15.1 (downloaded from Github)
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) Client VM (build 25.191-b12, mixed mode, sharing)
Play services - as installed via the Admob package
Tested on Android 8.1, API 27
I think some of the dependencies had a conflict and while the dependency resolver fixed them, ProGuard messed the things even more. Here is how I solved this particular problem:
Go to Build Settings > Player Setting > Publishing Settings (Player settings docs).
Enable custom ProGuard config.
Configure the proguard file to work for your problem. On my side the code snippet below does the job. But if you’re using additional dependencies they may conflict with this configuration. In such case it’s more of try and fail until the right config shows up… ProGuard docs.
-keep class com.google.unity.** {
*;
}
-keep public class com.google.android.gms.ads.**{
public *;
}
-keep public class com.google.ads.**{
public *;
}
-keepattributes *Annotation*
-dontobfuscate
For more details take a look at the blog post I've written about the issue.
NOTE: In more recent project with the newest version of AdMob and the Android SDK, the problem didn't appear. (As of May 2019)

UWP - SQLite issues when compiling in native

I was developing my app using SQLite, on "Debug" mode, worked perfectly.
When I try to "Release" it (Compiling "Native"), the problem started, looks like UWP doesn't support Reflexion.
I'm currently using this packages:
SQLite.Core.UAP
SQLite.Net-PCL
For example, if I try to do this:
private void CreateDatabase()
{
var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false);
SQLiteConn.CreateTable<StoredEvents>();
}
These are some of the error:
ILTransform_0027: Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found.
Error at SerializationAssemblyGenerator.Program.AddKnownContractsLists(McgCodeTypeDeclaration container, ContractTables tables)
Severity Code Description Project File Line Suppression State
Error at SerializationAssemblyGenerator.Program.GenerateDataContractSerializerHelperCode(IEnumerable`1 contracts, IEnumerable`1 jsonContracts, IEnumerable`1 wcfSerializers)
ILTransform_0000: MCG : warning MCG0006: Unresolved P/Invoke method '_TPM_Init!tpm.dll' in assembly 'TSS.UWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it is not available in UWP applications. Please either use an another API , or use [DllImport(ExactSpelling=true)
How should I refactor the code?
Should I use a different Library?
I had the same issue when i was updating my apps from Silverlight to UWP. I read an article somewhere ( Tried to find it but was unable to ) which says SQLlite for UWP is available for Windows 10 deployment.
The above is a VS Extension. You can get there from Tools ->> Extensions & Updates
Below is how my References look like.
Also I noticed that you are not closing your db connection. Always better to use it inside a using statement. your CreateTables() will look something like below.
private void CreateDatabase()
{
var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
using (SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false))
{
SQLiteConn.CreateTable<StoredEvents>();
}
}

Use Google Calendar API in User Control : System.IO.FileNotFoundException

I fail when trying to use the Google API v3 in a user control.
Steps:
Create a new project in Visual Studio Express 2013 Update 4. Target framework: .NET 4.5 (tried 4.0 too)
Install NuGet package "Google.Apis.Calendar.v3 Client Library" and all and all dependencies
Add new User Control "MyControl"
In MyCalendar_Load add the following line: CalendarService service = new ServiceCalendar();
Add using Google.Apis.Calendar.v3;
So the code of my control looks like:
using System;
using System.Windows.Forms;
using Google.Apis.Calendar.v3;
namespace Google_Calendar_Test
{
public partial class MyCalendar : UserControl
{
public MyCalendar()
{
InitializeComponent();
}
private void MyCalendar_Load(object sender, EventArgs e)
{
CalendarService service = new CalendarService();
}
}
}
Then I compile my solution so I get my newly created MyControl. When I try to put the control on the form the following error message appears:
System.IO.FileNotFoundException / Could not load file or assembly Google.Apis,
In the form I can add the CalendarService and start it without any problems. I'm puzzled.
Update
The version in the error message (V 1.0.0.23042) doesn't match to the version NuGet installed (V 1.0.0.26011). But this doesn't make any sense to me.

Adding Windows Azure Caching crashes Visual Studio 2012 with datacachefactory argument null exception

I've added the Windows Azure Cache 1.8.0 nuget package to my solution, but it ends up crashing Visual studio when I load the project. I've found that I can "prevent" the crashing by removing the dlls from the bin folder, and then again when visual studio adds them back to the bin while the project loads.
The dlls I'm removing are:
Microsoft.ApplicationServer.Caching.AzureClientHelper.dll
Microsoft.ApplicationServer.Caching.AzureCommon.dll
Microsoft.ApplicationServer.Caching.Client.dll
Microsoft.ApplicationServer.Caching.Core.dll
When I look at the event viewer for the visual studio crash I get this:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
Stack:
at System.Threading.Monitor.Enter(System.Object)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.Close()
at Microsoft.ApplicationServer.Caching.DataCacheFactory.Finalize()
I'm uncertain why VS is doing things with the dlls while the project is loading, but I admit I'm not an expert on that.
I've basically followed the process described on this page to add a dedicated cache worker role for caching:
http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/
I've tried removing and reinstalling the package, removing and reinstalling the Visual Studio SDK (Oct 2012), but the problem comes back.
Also, I don't have the App Fabric Server installed.
Thanks in advance for your help!
In case anyone else runs into this problem, I'm providing what seemed to work for me here.
In order to get visual studio to load the project, I removed the DLLs from the project. I also removed them as the project was loading and VS put the dlls back in the bin folder.
I removed the references to the dlls. Then I removed my code that was using the datacachefactory.
In the end I believe that it was caused by an improper use of the cache in my code that I had performed a build on. I was able to correct the usage of it, build the solution and get all the dlls back into the project.
Previously by datacache object had not be static.
here's my correct usage of the datacache factory:
using System;
using Microsoft.ApplicationServer.Caching;
namespace WebRole1.Classes
{
public class AzureCache
{
public static DataCache cache { get; set; }
public static DataCacheFactory dataCacheFactory { get; set; }
public AzureCache()
{
if (cache == null){
DataCacheFactoryConfiguration cfg = new DataCacheFactoryConfiguration();
cfg.AutoDiscoverProperty = new DataCacheAutoDiscoverProperty(true, "CacheWorkerRole1");
dataCacheFactory = new DataCacheFactory(cfg);
cache = dataCacheFactory.GetDefaultCache();
}
}
public void Add(string item, object value)
{
cache.Add(item, value);
}
public void Add(string item, object value, TimeSpan timeout)
{
cache.Put(item, value, timeout);
}
public object Get(string item)
{
return cache.Get(item);
}
public TimeSpan TimeRemaining (string item)
{
DataCacheItem DCitem = cache.GetCacheItem(item);
return DCitem.Timeout;
}
public void Flush()
{
cache.Clear();
DataCacheFactory cacheFactory = new DataCacheFactory();
cache = cacheFactory.GetDefaultCache();
}
}
}
We may need to capture a dump of the visual studio process(devenv.exe) to see what is causing this exception. You can use debugdiag("http://www.microsoft.com/en-us/download/details.aspx?id=26798") to capture the dump.
You may need to involve Microsoft support services("http://www.windowsazure.com/en-us/support/contact/") to further investigate this since the exception is coming from the cache code itself.
It's not an issue exclusively related to Visual Studio. I get it while running my webrole.
Check out this other article.

Categories

Resources