Xamarin.UITest REPL connection refused - c#

I'm beginning UI automated testing with Xamarin.UITest in Xamarin Studio. I'm using the basic CreditCardValidator project given by Xamarin. My tests work as expected, but when I try to add the line app.Repl(); to query the UI and enter the tree command (or any other for that matter), I keep getting the error:
App has been initialized to the 'app' variable.
Exit REPL with ctrl-c or see help for more commands.
>>> tree
Execution failed with exception: System.Net.WebException: Error:
ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) <0x3acc998 + 0x0017b> in <filename unknown>:0
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) <0x3aca8f8 + 0x004b7> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) <0x3acdbe8 + 0x00187> in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func`2 endFunction, System.Action`1 endAction, System.Threading.Tasks.Task`1 promise, Boolean requiresSynchronization) <0x1944280 + 0x00069> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x18aa010 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x18a7830 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x18a7790 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x18a7740 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x18a8040 + 0x00024> in <filename unknown>:0
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () <0x3abbe30 + 0x00df3> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at Xamarin.UITest.Shared.Http.HttpClient.Request (System.String method, System.String endpoint, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) <0x3aadc68 + 0x0040f> in <filename unknown>:0
at Xamarin.UITest.Shared.Http.HttpClient.Get (System.String endpoint, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) <0x3aadc18 + 0x0003b> in <filename unknown>:0
at Xamarin.UITest.Android.AndroidGestures.Dump () <0x3aadb18 + 0x00053> in <filename unknown>:0
at Xamarin.UITest.Utils.TreePrintHelper.PrintTree (ITreePrinter treePrinter) <0x3aada28 + 0x0002a> in <filename unknown>:0
at Xamarin.UITest.Queries.AppPrintHelper.Tree (Nullable`1 console) <0x3aad950 + 0x0008b> in <filename unknown>:0
at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x3aad830 + 0x00047> in <filename unknown>:0
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) <0x2ede1b0 + 0x0008f> in <filename unknown>:0
at Xamarin.UITest.Repl.Evaluation.MonoCSharpReplEngine.Evaluate (System.String line) <0x2ede0a0 + 0x00057> in <filename unknown>:0
at Xamarin.UITest.Repl.Repl.ReplFacade.RunCode (System.String code) <0x2edde88 + 0x00063> in <filename unknown>:0
at Xamarin.UITest.Repl.PromptHandler.PrintTree () <0x3aa4e50 + 0x0001f> in <filename unknown>:0
at Xamarin.UITest.Repl.PromptHandler.HandleInput (ConsoleKeyInfo key) <0x3a38520 + 0x001da> in <filename unknown>:0
at Xamarin.UITest.Repl.Program.Main (System.String[] args) <0x71def8 + 0x003ef> in <filename unknown>:0
Press any key to exit.
I have added the INTERNET permission in the app and the tests, themselves, run fine. The code for the tests is:
public class RecorderTest
{
public IApp app;
[SetUp]
public void Setup()
{
app = ConfigureApp.Android.Debug().ApkFile(<path/to/apk/>).StartApp();
}
[Test]
public void CreditCardNumberTooShortError()
{
//app.Repl();
app.Tap(x => x.Id("creditCardNumberText"));
app.Screenshot("Tapped on view with class: AppCompatEditText");
app.EnterText(x => x.Id("creditCardNumberText"), "1234");
app.Tap(x => x.Id("validateButton"));
app.Screenshot("Tapped on view with class: AppCompatButton");
AppResult[] result = app.Query(c => c.Class("AppCompatTextView").Text("Credit card number is too short."));
Assert.IsTrue(result.Any(), "The error message is not being displayed");
}
[Test]
public void CreditCardNumberTooLongError()
{
app.Repl();
app.EnterText(x => x.Marked("creditCardNumberText"), new String('9', 17));
app.Screenshot("Entered Credit card number");
app.Tap(x => x.Id("validateButton"));
app.Screenshot("Tapped on view with class: AppCompatButton");
AppResult[] result = app.Query(c => c.Id("errorMessagesText").Text("Credit card number is too long."));
Assert.IsTrue(result.Any(), "The error message is not being displayed");
}
}
I've used the Calabash Framework by Xamarin as well and I can use the console command and query the app just fine. Not sure whey this isn't working with Xamarin.UITest.
I'm running Java 1.7, NUnit 2.6.3 and Xamarin Studio 6.0.1 (build 9)

Related

"The property {property} does not exist on type {type}" - but it does. OData configuration issue?

I have a Blazor WASM application that has an OData back-end. I'm trying to configure the NavigationProperty of one of my models so that I can use the $expand= query parameter to return more data but I keep getting the following error when trying to make a PATCH request (GET works just fine):
Microsoft.OData.ODataException: The property 'JobId' does not exist on type 'Coin.ODataOrderHeader'. Make sure to only use property names that are defined by the type or mark the type as open type.
But it does exist! Not just in the model:
public partial class ODataOrderHeader
{
[Key]
public int OrderId { get; set; }
[Column("JobID")]
[ForeignKey("Job")]
public int JobId { get; set; }
...
[System.Text.Json.Serialization.JsonPropertyName("Job")]
public virtual Jobs Job { get; set; }
}
But in the $metadata document as well:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="Coin" xmlns="http://docs.oasis-open.org/odata/ns/edm">
...
<EntityType Name="ODataOrderHeader">
<Key>
<PropertyRef Name="OrderId" />
</Key>
<Property Name="OrderId" Type="Edm.Int32" Nullable="false" />
<Property Name="JobId" Type="Edm.Int32" />
...
<NavigationProperty Name="Job" Type="Coin.Jobs">
<ReferentialConstraint Property="JobId" ReferencedProperty="JobId" />
</NavigationProperty>
</EntityType>
...
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Here is the code that creates the model:
private IEdmModel GetEdmModel()
{
var builder = new ODataConventionModelBuilder();
builder.Namespace = "Coin";
builder.ContainerName = "CoinContainer";
...
var orders = builder.EntitySet<ODataOrderHeader>("Orders");
return builder.GetEdmModel();
}
I should probably point out, ODataOrderHeader is more of a DTO type whereas Jobs is an EF scaffolded type.
Here is the Simple.OData.Client code that calls the API:
private async void UpdateItem()
{
ODataClient client = new ODataClient(new ODataClientSettings(HttpClient, new Uri("odata", UriKind.Relative)));
await client.For<ODataOrderHeader>("Orders")
.Key(currentOrder.OrderId)
.Set(currentOrder)
.UpdateEntryAsync();
}
And here's the controller action that the above code is calling:
[ODataRoute("/orders({key})")]
public async Task<IActionResult> Patch([FromODataUri] int key, Delta<ODataOrderHeader> order)
{
if (!ModelState.IsValid)
return BadRequest();
...
}
And lastly, the error message in its entirety:
Unhandled Exception:
Microsoft.OData.ODataException: The property 'JobId' does not exist on type 'Coin.ODataOrderHeader'. Make sure to only use property names that are defined by the type or mark the type as open type.
at Microsoft.OData.WriterValidationUtils.ValidatePropertyDefined (Microsoft.OData.PropertySerializationInfo propertyInfo, System.Boolean throwOnUndeclaredProperty) <0x61a9028 + 0x00098> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WritePropertyInfo (Microsoft.OData.ODataPropertyInfo propertyInfo, Microsoft.OData.Edm.IEdmStructuredType owningType, System.Boolean isTopLevel, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x6120d78 + 0x000f8> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WriteProperty (Microsoft.OData.ODataProperty property, Microsoft.OData.Edm.IEdmStructuredType owningType, System.Boolean isTopLevel, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x61203e8 + 0x00018> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WriteProperties (Microsoft.OData.Edm.IEdmStructuredType owningType, System.Collections.Generic.IEnumerable`1[T] properties, System.Boolean isComplexValue, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x6011c28 + 0x00048> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightWriter.StartResource (Microsoft.OData.ODataResource resource) <0x5ef5478 + 0x003d6> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore+<>c__DisplayClass121_0.<WriteStartResourceImplementation>b__0 () <0x5ed80f0 + 0x00082> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore.InterceptException (System.Action action) <0x5ed3f20 + 0x00042> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore.WriteStartResourceImplementation (Microsoft.OData.ODataResource resource) <0x5ed3a78 + 0x00076> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore+<>c__DisplayClass49_0.<WriteStartAsync>b__0 () <0x5ed3628 + 0x0000c> in <filename unknown>:0
at Microsoft.OData.TaskUtils.GetTaskForSynchronousOperation (System.Action synchronousOperation) <0x5ed34e0 + 0x0000a> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at Simple.OData.Client.V4.Adapter.RequestWriter.WriteEntryPropertiesAsync (Microsoft.OData.ODataWriter entryWriter, Microsoft.OData.ODataResource entry, System.Collections.Generic.IDictionary`2[TKey,TValue] links) <0x5ed2260 + 0x000f2> in <filename unknown>:0
at Simple.OData.Client.V4.Adapter.RequestWriter.WriteEntryContentAsync (System.String method, System.String collection, System.String commandText, System.Collections.Generic.IDictionary`2[TKey,TValue] entryData, System.Boolean resultRequired) <0x5477750 + 0x0049c> in <filename unknown>:0
at Simple.OData.Client.RequestWriterBase.CreateUpdateRequestAsync (System.String collection, System.String entryIdent, System.Collections.Generic.IDictionary`2[TKey,TValue] entryKey, System.Collections.Generic.IDictionary`2[TKey,TValue] entryData, System.Boolean resultRequired) <0x5814b98 + 0x0020c> in <filename unknown>:0
at Simple.OData.Client.RequestBuilder.UpdateRequestAsync (System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x577cd28 + 0x00386> in <filename unknown>:0
at Simple.OData.Client.ODataClient.UpdateEntryAsync (Simple.OData.Client.FluentCommand command, System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x577bcc8 + 0x00162> in <filename unknown>:0
at Simple.OData.Client.BoundClient`1[T].UpdateEntryAsync (System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x576d9a0 + 0x00230> in <filename unknown>:0
at Coin.Client.Pages.OrderEdit.UpdateItem () [0x000ac] in C:\Users\trichardson\source\Workspaces\Corsi\COIN2\Client\Pages\OrderEdit.razor:393
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_1 (System.Object state) <0x6547930 + 0x0000c> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) <0x65478e0 + 0x00022> in <filename unknown>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x3112fc8 + 0x00100> in <filename unknown>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x310b7d8 + 0x00010> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x5743290 + 0x00038> in <filename unknown>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x39a89b8 + 0x00102> in <filename unknown>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x39a4578 + 0x00000> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.OData.ODataException: The property 'JobId' does not exist on type 'Coin.ODataOrderHeader'. Make sure to only use property names that are defined by the type or mark the type as open type.
at Microsoft.OData.WriterValidationUtils.ValidatePropertyDefined (Microsoft.OData.PropertySerializationInfo propertyInfo, System.Boolean throwOnUndeclaredProperty) <0x61a9028 + 0x00098> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WritePropertyInfo (Microsoft.OData.ODataPropertyInfo propertyInfo, Microsoft.OData.Edm.IEdmStructuredType owningType, System.Boolean isTopLevel, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x6120d78 + 0x000f8> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WriteProperty (Microsoft.OData.ODataProperty property, Microsoft.OData.Edm.IEdmStructuredType owningType, System.Boolean isTopLevel, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x61203e8 + 0x00018> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WriteProperties (Microsoft.OData.Edm.IEdmStructuredType owningType, System.Collections.Generic.IEnumerable`1[T] properties, System.Boolean isComplexValue, Microsoft.OData.IDuplicatePropertyNameChecker duplicatePropertyNameChecker, Microsoft.OData.Evaluation.ODataResourceMetadataBuilder metadataBuilder) <0x6011c28 + 0x00048> in <filename unknown>:0
at Microsoft.OData.JsonLight.ODataJsonLightWriter.StartResource (Microsoft.OData.ODataResource resource) <0x5ef5478 + 0x003d6> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore+<>c__DisplayClass121_0.<WriteStartResourceImplementation>b__0 () <0x5ed80f0 + 0x00082> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore.InterceptException (System.Action action) <0x5ed3f20 + 0x00042> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore.WriteStartResourceImplementation (Microsoft.OData.ODataResource resource) <0x5ed3a78 + 0x00076> in <filename unknown>:0
at Microsoft.OData.ODataWriterCore+<>c__DisplayClass49_0.<WriteStartAsync>b__0 () <0x5ed3628 + 0x0000c> in <filename unknown>:0
at Microsoft.OData.TaskUtils.GetTaskForSynchronousOperation (System.Action synchronousOperation) <0x5ed34e0 + 0x0000a> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at Simple.OData.Client.V4.Adapter.RequestWriter.WriteEntryPropertiesAsync (Microsoft.OData.ODataWriter entryWriter, Microsoft.OData.ODataResource entry, System.Collections.Generic.IDictionary`2[TKey,TValue] links) <0x5ed2260 + 0x000f2> in <filename unknown>:0
at Simple.OData.Client.V4.Adapter.RequestWriter.WriteEntryContentAsync (System.String method, System.String collection, System.String commandText, System.Collections.Generic.IDictionary`2[TKey,TValue] entryData, System.Boolean resultRequired) <0x5477750 + 0x0049c> in <filename unknown>:0
at Simple.OData.Client.RequestWriterBase.CreateUpdateRequestAsync (System.String collection, System.String entryIdent, System.Collections.Generic.IDictionary`2[TKey,TValue] entryKey, System.Collections.Generic.IDictionary`2[TKey,TValue] entryData, System.Boolean resultRequired) <0x5814b98 + 0x0020c> in <filename unknown>:0
at Simple.OData.Client.RequestBuilder.UpdateRequestAsync (System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x577cd28 + 0x00386> in <filename unknown>:0
at Simple.OData.Client.ODataClient.UpdateEntryAsync (Simple.OData.Client.FluentCommand command, System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x577bcc8 + 0x00162> in <filename unknown>:0
at Simple.OData.Client.BoundClient`1[T].UpdateEntryAsync (System.Boolean resultRequired, System.Threading.CancellationToken cancellationToken) <0x576d9a0 + 0x00230> in <filename unknown>:0
at Coin.Client.Pages.OrderEdit.UpdateItem () [0x000ac] in C:\Users\trichardson\source\Workspaces\Corsi\COIN2\Client\Pages\OrderEdit.razor:393
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_1 (System.Object state) <0x6547930 + 0x0000c> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) <0x65478e0 + 0x00022> in <filename unknown>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x3112fc8 + 0x00100> in <filename unknown>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x310b7d8 + 0x00010> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x5743290 + 0x00038> in <filename unknown>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x39a89b8 + 0x00102> in <filename unknown>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x39a4578 + 0x00000> in <filename unknown>:0
Uncaught ExitStatusThe program '' has exited with code -1 (0xffffffff).
Is there a configuration error I'm missing or is there something wrong with the controller action?
For anyone that stumbles across this in the future, I was able to uncover a little more information.
Firstly, by adding some data annotations [IgnoreDataMember] on my Jobs class and by adding {IgnoreUnmappedProperties = true} when instantiating the ODataClient, I was able to get a different error. Something along the lines of: The key 'JobId' does not exist in the dictionary.
For context, I'm trying to do what OData refers to as a "deep update". I want to update a child entity while updating the parent entity. However, Simple.OData.Client does not support deep updates or deep linking or deep creation. Here's a 5 year old question from Simple.OData.Client's GitHub page that talks about this and unfortunately, it would appear that development of this package has ceased ("Future of Simple.OData.Client" and "Project Dead?"). Since it doesn't support "deep updates", it doesn't know how to generate the request URL which is why my PATCH request was failing.

Mono IPv4 versus IPv6 issues: SocketException: Invalid arguments

I have a Mono .NET application that uses ppatierno.AzureSBLite to receive data from an Azure ServiceBus.
The code is straightforward:
var factory = MessagingFactory.CreateFromConnectionString(connectionString);
var client = factory.CreateEventHubClient(eventHubEntity);
var group = client.GetDefaultConsumerGroup();
var receiver = group.CreateReceiver(partitionId, startingDateTimeUtc);
EventData = receiver.Receive();
On my VM running 64-bit Ubuntu 16.04, using Ubuntu's Mono packages, it works flawlessly.
On my build server running Ubuntu 14.04, in a 64-bit 16.04 chroot (so the chroot environment should have all of the same userland packages as the VM), using Ubuntu's Mono packages, I get the following error:
System.Net.Sockets.SocketException: Invalid arguments
at System.Net.Sockets.Socket.BeginMConnect (System.Net.Sockets.SocketAsyncResult sockares) <0x41029e20 + 0x001df> in <filename unknown>:0
at System.Net.Sockets.Socket.BeginConnect (System.Net.IPAddress[] addresses, Int32 port, System.AsyncCallback callback, System.Object state) <0x41029720 + 0x00107> in <filename unknown>:0
at System.Net.Sockets.Socket.BeginConnect (System.String host, Int32 port, System.AsyncCallback callback, System.Object state) <0x41027720 + 0x0008f> in <filename unknown>:0
at Amqp.TcpTransport+<>c__DisplayClass3.<ConnectAsync>b__0 (System.AsyncCallback c, System.Object s) <0x41027670 + 0x00073> in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncImpl (System.Func`3 beginMethod, System.Func`2 endFunction, System.Action`1 endAction, System.Object state, TaskCreationOptions creationOptions) <0x7fc54c2c8700 + 0x001cf> 24334 in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7fc54c0016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7fc54bfff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7fc54bfff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7fc54bfff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7fc54bfff5c0 + 0x00012> in <filename unknown>:0
at Amqp.TcpTransport.Connect (Amqp.Connection connection, Amqp.Address address, Boolean noVerification) <0x410219b0 + 0x0015e> in <filename unknown>:0
at Amqp.Connection.Connect (Amqp.Sasl.SaslProfile saslProfile, Amqp.Framing.Open open) <0x41021680 + 0x0006b> in <filename unknown>:0
at Amqp.Connection..ctor (Amqp.Address address, Amqp.Sasl.SaslProfile saslProfile, Amqp.Framing.Open open, Amqp.OnOpened onOpened) <0x4101ba40 + 0x00227> in <filename unknown>:0
at Amqp.Connection..ctor (Amqp.Address address) <0x4101b9b0 + 0x0001b> in <filename unknown>:0
at ppatierno.AzureSBLite.Messaging.Amqp.AmqpMessagingFactory.Open (System.String entity) <0x4101b760 + 0x001b7> in <filename unknown>:0
at ppatierno.AzureSBLite.Messaging.Amqp.AmqpMessageReceiver.ReceiveEventData () <0x4101afb0 + 0x00042> in <filename unknown>:0
at ppatierno.AzureSBLite.Messaging.EventHubReceiver.Receive () <0x4101ab40 + 0x0001f> in <filename unknown>:0
at ReceiveEdgeData.EdgeReceiver.MainLoop () <0x4101a920 + 0x0004b> in <filename unknown>:0
If I understand the strace output correctly, the non-functioning host is creating an IPv6 socket and trying to directly connect to an IPv4 address:
connect(4, {sa_family=AF_INET, sin_port=htons(5671), sin_addr=inet_addr("52.176.47.198")}, 16) = -1 EINVAL (Invalid argument)
While the functioning host is using something like dual-mode sockets to correctly represent the IPv4 address as an IPv6 address:
connect(4, {sa_family=AF_INET6, sin6_port=htons(5671), inet_pton(AF_INET6, "::ffff:52.176.47.198", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EINPROGRESS (Operation now in progress)
Given that this is happening somewhere inside Mono and its dependencies, how do I troubleshoot and fix this?

SignalR run with Mono and apache: HTTP 500 error (in SignalR code)

I've been running SignalR on mono with both self-hosting on localhost and on IIS.
But self-hosting with mono on a server didn't work yet
The full error I get on the webpage is:
System.InvalidOperationException
Operation is not valid due to the current state of the object.
Description:` HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): Microsoft.Owin.Host.SystemWeb.
Exception stack trace:
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent (System.Object sender, System.EventArgs e, System.AsyncCallback cb, System.Object extradata) <0x404788f0 + 0x0074b> in <filename unknown>:0
at System.Web.HttpApplication+<RunHooks>c__Iterator0.MoveNext () <0x404715e0 + 0x00367> in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () <0x40468000 + 0x01a65> in <filename unknown>:0
at System.Web.HttpApplication.Tick () <0x40465950 + 0x00057> in <filename unknown>:0
In the Apache error log:
Cannot access a closed Stream.
at System.IO.MemoryStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) <0x4006e720 + 0x0008b> in <filename unknown>:0
at System.IO.BinaryWriter.Write (Int32 value) <0x4006e660 + 0x00087> in <filename unknown>:0
at Mono.WebServer.ModMonoRequest.IsConnected () <0x40540670 + 0x0001f> in <filename unknown>:0
at Mono.WebServer.Apache.ModMonoWorker.IsConnected () <0x40540640 + 0x0001b> in <filename unknown>:0
at Mono.WebServer.ModMonoWorkerRequest.IsClientConnected () <0x405405b0 + 0x00030> in <filename unknown>:0
at System.Web.HttpResponse.get_IsClientConnected () <0x40540570 + 0x0002a> in <filename unknown>:0
at System.Web.HttpResponseWrapper.get_IsClientConnected () <0x40540540 + 0x0001b> in <filename unknown>:0
at Microsoft.Owin.Host.SystemWeb.OwinCallContext.CheckIsClientConnected (System.Object obj) <0x40540490 + 0x00051> in <filename unknown>:0
at System.Threading.Timer+Scheduler.TimerCB (System.Object o) <0x4053daf0 + 0x001a7> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x403d3c60 + 0x0002f> in <filename unknown>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x403d09b0 + 0x0021a> in <filename unknown>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x403d0980 + 0x00010> in <filename unknown>:0
My code looks just fine, my program.cs contains:
class Program
{
static void Main(string[] args)
{
string url = "http://*:80";
using (Microsoft.Owin.Hosting.WebApp.Start<Startup>(url))
{
}
}
}
I have no idea what to do, should I look to change something in my code to let it work with mono?
I'm going to use SignalR Core, problem solved! :)

The "CollectBundleResources" task failed unexpectedly

I'm newbie to learn xamarin. When i download sample and build but I got error
Severity Code Description Project File Line Suppression State
Error The "CollectBundleResources" task failed unexpectedly.
Xamarin.Messaging.Exceptions.MessagingRemoteException: An error occured on client Build403214 while executing a reply for topic xvs/Build/4.0.3.214/copy-item/SamplyGameiOS/25940bb/CoreData.pak ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/Users/niennguyen/Library/Caches/Xamarin/mtbs/builds/SamplyGameiOS/25940bb6fa00542affd423f61b9739d0/D:/SamplyGame/packages/UrhoSharp.1.0.410/build/Xamarin.iOS10/../../native"
at System.IO.Directory.CreateDirectoriesInternal (System.String path) <0x19fb700 + 0x00148> in <filename unknown>:0
at System.IO.Directory.CreateDirectory (System.String path) <0x19fb4f0 + 0x000c7> in <filename unknown>:0
at Xamarin.Messaging.Build.Handlers.CopyItemMessageHandler+<>c__DisplayClass1_0.<ExecuteAsync>b__0 () <0x33203b8 + 0x000b7> in <filename unknown>:0
at System.Threading.Tasks.Task.InnerInvoke () <0x1935f30 + 0x00051> in <filename unknown>:0
at System.Threading.Tasks.Task.Execute () <0x1935780 + 0x0004d> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x188f5d0 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x188cf00 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x188ce60 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x188ce10 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () <0x188d3c0 + 0x0001f> in <filename unknown>:0
at Xamarin.Messaging.Build.Handlers.CopyItemMessageHandler+<ExecuteAsync>d__1.MoveNext () <0x3320000 + 0x00253> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x188f5d0 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x188cf00 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x188ce60 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x188ce10 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x188cde0 + 0x0001f> in <filename unknown>:0
at Xamarin.Messaging.Client.RequestHandler`1+<HandleAsync>d__5[TMessage].MoveNext () <0x331f780 + 0x0035b> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x188f5d0 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x188cf00 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x188ce60 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x188ce10 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () <0x188d3c0 + 0x0001f> in <filename unknown>:0
at Xamarin.Messaging.Client.MessageHandlerManager+<>c__DisplayClass17_1`1+<<RegisterHandlerAsync>b__3>d[TMessage].MoveNext () <0x331f110 + 0x00257> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x188f5d0 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x188cf00 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x188ce60 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x188ce10 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x188cde0 + 0x0001f> in <filename unknown>:0
at Xamarin.Messaging.Client.MessagingClient+<>c__DisplayClass36_0`1+<<ReplyAsync>b__0>d[TRequest].MoveNext () <0x331eba0 + 0x0011b> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x188f5d0 + 0x00035> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x188cf00 + 0x000b7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x188ce60 + 0x00087> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x188ce10 + 0x0003f> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x188d600 + 0x00024> in <filename unknown>:0
at Xamarin.Messaging.Client.MessagingClient+<ReplyAsync>d__34`2[TRequest,TResponse].MoveNext () <0x31f70e0 + 0x00383> in <filename unknown>:0
--- End of inner exception stack trace ---
at Xamarin.Messaging.Client.MessagingClient.<PostAsync>d__23`2.MoveNext() in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\MessagingClient.cs:line 188
--- 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 Xamarin.Messaging.Client.MessagingClient.<PostAsync>d__22`2.MoveNext() in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\MessagingClient.cs:line 0
--- 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 Xamarin.Messaging.Client.MessagingClient.<PostAsync>d__26`2.MoveNext() in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\MessagingClient.cs:line 0
--- 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 Xamarin.Messaging.Client.MessagingClient.<PostAsync>d__32`1.MoveNext() in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\MessagingClient.cs:line 306
--- End of stack trace from previous location where exception was thrown ---
at Xamarin.Messaging.Client.IMessagingClientExtensions.Execute(Action postAction) in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\Extensions\IMessagingClientExtensions.cs:line 231
at Xamarin.Messaging.Client.IMessagingClientExtensions.Post[TRequest](IMessagingClient client, TRequest request, Boolean retain, Int32 timeoutSecs) in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\Messaging\Xamarin.Messaging.Client\Extensions\IMessagingClientExtensions.cs:line 195
at Xamarin.VisualStudio.Build.BuildClient.UploadItem(String path) in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\MSBuild\Xamarin.VisualStudio.Build\BuildClient.cs:line 99
at Xamarin.VisualStudio.Build.TaskRunner.CopyRequiredInputFiles(Task task) in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\MSBuild\Xamarin.VisualStudio.Build\TaskRunner.cs:line 219
at Xamarin.MacDev.Tasks.CollectBundleResources.Execute() in C:\Users\builder\data\lanes\3062\0dd817c0\source\XamarinVS\src\MSBuild\Xamarin.MacDev.Tasks\Tasks\CollectBundleResources.cs:line 14
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() SamplyGame.iOS

c# mono raspberry pi GPIO with Raspberry# getting Operation is not valid

I'm trying to use Raspberry# library to perform basic task whith GPIO pin on Raspberry PI (on and off).
As per example on github: https://github.com/raspberry-sharp/raspberry-sharp-io/wiki/Raspberry.IO.GeneralPurpose
Code:
var led1 = ConnectorPin.P1Pin11.Output();
var connection = new GpioConnection(led1);
for (var i = 0; i < 100; i++)
{
connection.Toggle(led1);
System.Threading.Thread.Sleep(250);
}
connection.Close();
on line var connection = new GpioConnection(led1); I get exception:
"Operation is not valid due to the current state of the object"
Stack trace
Unhandled Exception:
System.InvalidOperationException: Operation is not valid due to the current state of the object
at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in <filename unknown>:0
at Hello.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Operation is not valid due to the current state of the object
at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in <filename unknown>:0
at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in <filename unknown>:0
at Hello.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
I am able to switch pin state with Python so nothing is wrong with device.
Execute your Mono program as root. /dev/mem is not accessible to normal users.
public GpioConnectionDriver() {
using (var memoryFile = UnixFile.Open("/dev/mem", UnixFileMode.ReadWrite | UnixFileMode.Synchronized)) {
gpioAddress = MemoryMap.Create(
IntPtr.Zero,
Interop.BCM2835_BLOCK_SIZE,
MemoryProtection.ReadWrite,
MemoryFlags.Shared,
memoryFile.Descriptor,
Interop.BCM2835_GPIO_BASE
);
}
}
Explanation from here:
http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=22515
To open /dev/mem you need both regular access permissions on the device file and the security capability CAP_SYS_RAWIO, or to be root. There is no getting around this, because full access to memory allows a lot more than just GPIO. It has huge security implications.

Categories

Resources