Using Azure storage on Mac with ASP.NET vNext - asp.net

Trying to read data from Azure TableStorage in MVC 6 application on Mac.
It works on PC, but when on Mac it used to give this error:
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>, line 0Stack Query Cookies Headers Environment
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTableClient.ExecuteAsync (System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableOperation operation, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTable+<>c__DisplayClass4+<<ExistsAsync>b__5>d__0.MoveNext () [0x00000] in <filename unknown>
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>
System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00000] in <filename unknown>
After following this discussion and installing System.Net.Http package using kpm I started to get a new error:
An unhandled exception occurred while processing the request.NullReferenceException: Object reference not set to an instance of an object
Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpClientFactory.BuildHttpClient[TableResult] (Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1 cmd, System.Net.Http.HttpMessageHandler handler, Boolean useVersionHeader, Microsoft.WindowsAzure.Storage.OperationContext operationContext) [0x00000] in <filename unknown>, line 0
Note:
I had the System.Net.Http package installed in "aspnetcore50": { "dependencies": { ... } }, but it seems like it had to be installed in the common dependencies
Any idea why that might happen and how to fix it?

You cannot use Azure Storage .NET client under aspnetcore50, it's not available for this runtime. You need to pull it under aspnet50 (dnx451 now).

Related

get api worked fine but the post shows an exception while debugging in a physical device

I'm consuming some asp.net core APIs in my physical device, the get api worked fine but the post api shows an exception while debugging that tells that the url is invalid, but I tested it in swagger and it worked fine!
the exception :
System.InvalidOperationException: An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.
at System.Net.Http.HttpClient.PrepareRequestMessage (System.Net.Http.HttpRequestMessage request) [0x0008a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:678
at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x00020] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:437
at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:418
at System.Net.Http.HttpClient.PostAsync (System.Uri requestUri, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken) [0x00013] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:335
at System.Net.Http.HttpClient.PostAsync (System.Uri requestUri, System.Net.Http.HttpContent content) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:321
at System.Net.Http.HttpClient.PostAsync (System.String requestUri, System.Net.Http.HttpContent content) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:316
at ADD.Services.ApiMachineService.AddMachine (ADD.Models.Machine machine) [0x0000f] in C:\Users\amyra\source\repos\ADD\ADD\Services\ApiMachineService.cs:22
at ADD.ViewModels.ajoutVM.SaveMachine () [0x00072] in C:\Users\amyra\source\repos\ADD\ADD\ViewModels\ajoutVM.cs:37
[Choreographer] Skipped 30 frames! The application may be doing too much work on its main thread.

Cannot access a disposed object.\nObject name: 'PrimaryToolbarItem'

I created a ToolbaItems in a ContentPage that is a ShellContent from FlyoutItem - I am using ShellApp.
<ContentPage.ToolbarItems>
<ToolbarItem
x:Name="xicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.x.png}"
Text="Saw X" />
<ToolbarItem
x:Name="yicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.y.png}"
Text="Saw Y" />
<ToolbarItem
x:Name="zicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.z.png}"
Text="Saw Z" />
</ContentPage.ToolbarItems>
In Android it works well, but in iOS I got an error:
Message "Cannot access a disposed object.\n
Object name: 'PrimaryToolbarItem'." string
$exception {System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'PrimaryToolbarItem'.
at Foundation.NSObject.get_SuperHandle () [0x00012] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:469
at UIKit.UIBarButtonItem.set_Image (UIKit.UIImage value) [0x0002b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIBarButtonItem.g.cs:827
at Xamarin.Forms.Platform.iOS.ToolbarItemExtensions+PrimaryToolbarItem.UpdateIconAndStyle () [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\ToolbarItemExtensions.cs:84
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at Toretto.MobileApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Projects\Toretto\Toretto.MobileApp\src\Toretto.MobileApp\Toretto.MobileApp.iOS\Main.cs:17 } System.ObjectDisposedException
If I remove theses items in the constructor of the ContentPage it does not crash, I tried to use only Text, in Android I am using icon and works...
public HomePage()
{
InitializeComponent();
if (DeviceInfo.Platform == DevicePlatform.iOS)
{
this.ToolbarItems.Clear();
}
}
Is this a bug? In github I saw few issue about toolbar.
Yes, it is just the case. It is a known issue, and xamarin development team have added this to To do in xamarin form v5.0.1.
You can follow it up here:https://github.com/xamarin/Xamarin.Forms/issues/6387.
We are sorry for the inconvenience.And thanks for your support for xamarin.

How to connect a CITIZEN printer to Xamarin.Forms app?

I'm developing a mobile app with xamarin.forms, this app make a bluetooth connection to the CITIZEN printer. The printer has a plugin for xamarin.forms. This plugin is imported into the project; but when I try connect the printer from the application, it returns the following error:
Excepcion: Didn't find class "com.citizen.jpos.printer.CPCLPrinter" on path: DexPathList[[zip file "/data/app/com.companyname.facturaimpresion2.x_0-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.facturaimpresion2.x_0-1/lib/arm, /vendor/lib, /system/lib]]. StackTrace: at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00129] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniType.GetCachedJniType (Java.Interop.JniType& cachedType, System.String classname) [0x00018] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers.get_JniPeerType () [0x0000c] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.get_JniPeerType () [0x00014] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x0003f] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Com.Citizen.Jpos.Printer.CPCLPrinter..ctor () [0x00034] in <e141e43239ef42c4af494152c936c094>:0
at Plugin.CitizenXamarinSDK.CitizenXamarinCPCLImplementation.connect (System.String macAddress) [0x0009b] in <1427ae75e5b64afe9c92e8161f8405b8>:0
at facturaImpresion2._0.MainPage.OnConnectableDeviceSelection (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x00119] in C:\Users\segador\source\repos\FacturaImpresion\facturaImpresion2.0\facturaImpresion2.0\MainPage.xaml.cs:537
--- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: Didn't find class "com.citizen.jpos.printer.CPCLPrinter" on path: DexPathList[[zip file "/data/app/com.companyname.facturaimpresion2.x_0-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.facturaimpresion2.x_0-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at crc643f46942d9dd1fff9.CellAdapter.n_onItemClick(Native Method)
at crc643f46942d9dd1fff9.CellAdapter.onItemClick(CellAdapter.java:89)
at android.widget.AdapterView.performItemClick(AdapterView.java:305)
at android.widget.AbsListView.performItemClick(AbsListView.java:1185)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3222)
at android.widget.AbsListView$3.run(AbsListView.java:4138)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5576)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
Suppressed: java.lang.ClassNotFoundException: com.citizen.jpos.printer.CPCLPrinter
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

ASP.NET core startup fatal error - impossible to run the project with normal .net references

I have .NET Core 1.1.1 web project that I can't run properly. I'm compiling against .NET 452 or/and .NET 462, this project has several regular .NET libraries references. The exception that I'm getting is:
System.AggregateException was unhandled
HResult=-2146233088
Message=An error occurred while writing to logger(s).
Source=Microsoft.Extensions.Logging
StackTrace:
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(ILogger logger, EventId eventId, Exception exception, String message, Object[] args)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at ClientFacingWeb.Program.Main(String[] args) in E:\..\ClientFacingWeb\Program.cs:line 18
InnerException:
HResult=-2147467262
Message=Unable to cast object of type 'System.Configuration.Internal.ConfigurationManagerInternal' to type 'System.Configuration.TimeSpanValidator'.
Source=System
StackTrace:
at System.Configuration.ConfigurationManagerInternalFactory.get_Instance()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
at System.Diagnostics.TraceInternal.InitializeSettings()
at System.Diagnostics.TraceInternal.WriteLine(String message, String category)
at Microsoft.Extensions.Logging.Debug.DebugLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
InnerException:
The message being printed in the console is:
Compilation=DEBUG
Environment=Development
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.AggregateException: One or more errors occurred. ---> System.Configuration.ConfigurationErrorsException: The configuration is read only.
at System.Configuration.ConfigurationElementCollection.BaseRemoveAt(Int32 index)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Net.Configuration.SettingsSectionInternal.get_Section()
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.IPAddress.InternalParse(String ipString, Boolean tryParse)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.CreateIPEndpoint(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__12.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
---> (Inner Exception #0) System.Configuration.ConfigurationErrorsException: The configuration is read only.
at System.Configuration.ConfigurationElementCollection.BaseRemoveAt(Int32 index)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Net.Configuration.SettingsSectionInternal.get_Section()
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.IPAddress.InternalParse(String ipString, Boolean tryParse)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.CreateIPEndpoint(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__12.MoveNext()<---
If I remove those regular .NET references the project executes successfully.
I'm not able to identify which one of the references is causing the error.
I have look into the output window too see the loaded modules, and none of the loaded modules are different if I use, have or not my regular .NET project/library references.

realm in Xamarin, System.EntryPointNotfoundException when trying to use realm

I have installed realm in a Xamarin app and when I try to use an object (count, write, etc) it gives me a System.EntryPointNotFoundException.
Below code:
_realm = Realm.GetInstance();
_realm.Write(() =>
{
var myConfig = _realm.CreateObject<Config>();
myConfig.Email = "";
myConfig.User = "";
});
System.EntryPointNotFoundException: shared_realm_begin_transaction
at at (wrapper managed-to-native) Realms.NativeSharedRealm:begin_transaction (Realms.SharedRealmHandle)
at Realms.Transaction..ctor (Realms.SharedRealmHandle sharedRealmHandle) [0x0000d] in :0
at Realms.Realm.BeginWrite () [0x00000] in :0
at Realms.Realm.Write (System.Action action) [0x00000] in :0
at rasoApp.ConfigViewModel..ctor () [0x00025] in /Users/luis/Projects/rasoApp/rasoApp/viewModels/ConfigViewModel.cs:22
at rasoApp.ConfigPage.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x0000e] in /Users/luis/Projects/rasoApp/rasoApp/views/ConfigPage.xaml.cs:13
at rasoApp.HomePage.btnOpenConfig (System.Object sender, System.EventArgs e) [0x00007] in /Users/luis/Projects/rasoApp/rasoApp/views/HomePage.xaml.cs:18
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x00020] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x0000e] in :0
at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIControl.cs:38
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:63
at rasoApp.iOS.Application.Main (System.String[] args) [0x00008] in /Users/luis/Projects/rasoApp/iOS/Main.cs:17
Congratulations on an interesting problem!
I have seen a similar error but only in recent work I was doing refining code generation, when I generated bad IL code. We have no previous issues recorded nor any discussions of EntryPointNotFoundException messages that I can find.
If you try building one of our examples from the Realm source download, such as QuickJournal does that work?
If you can send a full project demonstrating the problem to help#realm.io that is probably the fastest way to work out what is happening.
Update 2016-07-11
Looking at another SO question made me think of a few more things to try:
Does this happen on all platforms?
- Do you have Full Linking enabled in Xamarin studio?
Earlier Suggestions
Does your app have a PCL containing that logic?
Did you also install the Realm NuGet into the main application (IOS or Android) projects? That is a necessary step. The main Realm libraries are only included with the platform-specific dlls which NuGet adds to IOS or Android projects.

Resources