Error "Frame not in module." in Xamarin.Forms - Android project - c#

Whenever it comes to this line, this error appears:
using (var client = new HttpClient())
{
var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros");
var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json);
return livros;
}
A new tab appears in VS that says "Frame not in module."
It happens whenever the thread arrives at the using line.
Frame not in module
This is code complete...
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace LivrosApp.ApiLivros
{
public static class Api
{
public static async Task<IList<Model.Livro>> GetAsync()
{
using (var client = new HttpClient())
{
var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros");
var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json);
return livros;
}
}
}
}

Annoying when this happens!!
There is not one solution to this, have had this issue in past and few things you can try:
Change linking options -->Clean -->build
Change fast deployment --> build
Make sure mdb files are been generated and switch debug info
generation to all/pdb files and rebuild
Exception settings -> Common Language Runtime Exceptions (should be ticked) If unticked tick the parent level so that everything below it is ticked
Tools -> Options -> Debugging -> General -> Enable Just My Code
(Ticked)
If none of them works then try stepping over (F10) instead of step
into (F11)
Hopefully atleast one solution works!!

I had the same problem and it worked for me after I make the following change.
Go to Debug -> Exceptions -> Uncheck Common Language Runtime Exception
Source where I get the solution from: Debbuger doesn't work frame not in module.

Related

what reference I need to add in C# to get LaunchPadApi?

I try to connect to the API (Using C#) that client provided, but it is using LaunchPadApi() I am not sure what assembly I need to add to get this, these are 2 references that were added:
using IO.Swagger.Api;
using IO.Swagger.Client;
I was able to find using IO.Swagger.Client; but I am not able to find using IO.Swagger.Api;
This is a sample code I am not sure how I can get LaunchPadApi defined so "responsePost" method is not recognized as well,
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
public class responsePostExample
{
public void main()
{
var apiInstance = new LaunchPadApi();
....
try
{
apiInstance.responsePost(body, xAPIKey);
}
....
Install Launchpad in your nuget package manager for the project
Add using Launchpad; to the top of your file

Visual Studio / RestSharp - Cannot navigate to the symbol under the caret (CS0118)

I have only been coding for about two years now (off and on) but I'm well acquainted with this cryptic error across multiple versions of VS. I know this issue isn't related to just RestSharp.
This 'caret error' has been the bane of my VS experience so that is why I'm here.
Environment:
Microsoft Visual Studio Community 2019 Version 16.8.1
RestClient v4.0.30319
Windows 10 Professional
What I'm trying to do:
I'm following the very simple directions on the RestClient site. I have installed RestClient, added references but when I try to get started I get that dreaded caret error.
None of this is my code aside from the reference to RestClient, which may or may not be appropriate (I don't know).
Screen Snip
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RestSharp;
using RestSharp.Authenticators;
using RestClient;
namespace newDawn2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var client = new RestClient("https://api.twitter.com/1.1");
client.Authenticator = new HttpBasicAuthenticator("username", "password");
var request = new RestRequest("statuses/home_timeline.json", DataFormat.Json);
var response = client.Get(request);
}
}
}
Thanks for reading.
using RestClient;
Here you are declaring that you are using the namespace RestClient, not the object.
var client = new RestClient(...
The error is raised here because you are trying to create an instance of the namespace you just declared you were using.
It's uncommon and confusing for an object to share a name with part of its namespace, so you should generally not expect to see a using statement with the same name you use to create an object.
Namespaces are used to separate, organize classes and limit what classes are loaded at compile time.
Classes of the same name can exist in different namespaces.
You could create your own class named RestClient and use it in this project as well(maybe for testing) as long as they existed in different namespaces. The full declaration of the class you are using now is RestSharp.RestClient. You could create a class with the full declaration Facundo.Test.RestClient and use them both in the same project. However, in this case, you could not use using statements and everytime you wanted to instantiate one or the other you would need to fully declare the namespace
RestSharp.RestClient client = new RestSharp.RestClient(...);
or
Facundo.Test.RestClient testClient = new Facundo.Test.RestClient(...);
I would not recommend naming them the same in practice, just trying to illustrate namespaces.

ˋ[System.Version]::Parse('')´ error in Xamarin

I have been trying to create a custom control on Xamarin.Forms.
My solution builds just fine on UWP but with android I always get the same error :
Impossible to evaluate the expression "[System.Version]::Parse('')". String is either too long or too short.
How Can I solve this ???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using App2;
using App2.UWP;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml.Controls;
[assembly: ExportRenderer(typeof(NavigationPannel), typeof(NavigationPannelRenderer))]
namespace App2.UWP
{
class NavigationPannelRenderer : ViewRenderer<NavigationPannel, NavigationView>
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPannel> args)
{
base.OnElementChanged(args);
if (Control == null)
{
NavigationView nav_view = new NavigationView();
nav_view.MenuItems.Add(new NavigationViewItem
{
Content = "My content",
Icon = new SymbolIcon(Symbol.Folder),
Tag = "content"
});
SetNativeControl(nav_view);
}
}
}
}
EDIT :
I made another solution and tried to redo everything step by step, my android project compiled just fine at first, but when I Added my UWP custom renderer, and after compiling it on Windows, it started showing the same error
Okay so I made it step by step again copy/pasting line by line for a third time and this time no error occurs.
I really don't know what happened here so if anyone has any idea i would still gladly accept it.

Load the solution in which the Stand-Alone code Analyser is being written

I was trying to write an analyser to get information about some methods using the roslyn syntax tree. The problem is: The analyser that I am writing, needs to be in the same solution as the solution that I want to analyse.
So, this is my code:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public static class Main
{
public static Solution solution { get; set; } = null;
public static string GetMethodInfo(string methodToFind)
{
Task<Solution> GetSolutionTask = null;
string namespaceToFind, classToFind, methodToFind, invocationToFind;
if (solution == null)
{
var workspace = Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create();
GetSolutionTask = workspace.OpenSolutionAsync(Config.SolutionPath);
}
if (GetSolutionTask != null) solution = GetSolutionTask.Result;
foreach (Project proj in solution.Projects)
{
Compilation compilation = proj.GetCompilationAsync().Result;
foreach (var tree in compilation.SyntaxTrees)
{
findMethodAndProcessIt()...
}
}
return String.Empty;
}
}
The problem I get is that no compilation has any syntax tree. I tried this same code by opening other solutions and it works. So clearly the problem here is to be trying to open the solution that the visual studio is using.
I have already tried to run this code with visual studio closed, only running the .exe , but the problem persists.
Do you have any idea on how to solve this?
You are using MSBuildWorkspace to open a solution. Typically, when use of MSBuildWorkspace leads to projects not being loaded correctly, no source files, etc, there has been a failure during msbuild processing. This usually happens when your application does not have the same binding redirects in its app.config file that msbuild uses (in msbuild.exe.config), which causes some custom tasks/extensions to fail to load due to versioning mismatch.
You'll want to copy the <assemblyBinding> section into your app.config.

Visual Studio 2015 update 3 code coverage issues

I am currently working with Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 and have used an MS c# example program to test the built-in unit test and code coverage function. The unit test is working perfectly fine, but everytime I try to start code coverage after the test finished, I get an error message saying:
"Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see: http://go.microsoft.com/fwlink/?LinkID=253731.".
Of course, I checked the link for troubleshooting and worked through all listed issues there, but without any success. I also tried several solutions which should have worked in earlier versions (use command promp to instrument binary or to run code coverage, deleting test results Folder and the VS Solution User Option .suo file, etc.), but still haven't found anything useful working for my case.
Does anybody face the same problem or knows a possible solution for it?
Thank you very much in advance!
Best,
Steve
PS: I am using the standard settings, but with all optimizations turned off. My test project is located in the same solution as my source project I want to test. Here is the code for the example program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace codecoverage
{
public class Program
{
static void Main(string[] args)
{
Program prog = new Program();
prog.TestFunction(0);
}
public int TestFunction(int input)
{
if (input > 0)
{
return 1;
}
else
{
return 0;
}
}
}
}
The Test Class is defined as followed:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using codecoverage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace codecoverage.Tests
{
[TestClass()]
public class ProgramTests
{
[TestMethod()]
public void TestFunctionTest2()
{
Program target = new Program();
int input = 1;
int expected = 1;
int actual;
actual = target.TestFunction(input);
Assert.AreEqual(expected, actual, "CodeCoverage.Program.TestFunction did not return the expected value.");
}
}
}
i have been looking for the solution. and found that it's actually a PDB file problem. all you need to do is to go to this linker tab->debugging. and set option "Generate full program database file" to Yes. this is due to the change VS2015 introduced for /Debug:FASTLINK. setting it to 'yes' would override it.

Categories

Resources