Xamarin Studio code completion and navigation not working - c#

Yesterday I upgraded Xamarin Studio on my Mac (10.12.4) to 6.1.5 (build 0) community edition.
If I create a new project, everything works as expected, but in my existing solution that is quite extensive, code completion, symbol navigation (e.g., right-clicking a symbol to find references), and brace matching are all not functioning.
Note: It seems to be functioning properly in XAML files, but not CS files. This is strange, since everything I could find searching appears to suggest the opposite is the most likely circumstance.
Here are the things I've tried so far to remedy it:
Removing and reinstalling Xamarin Studio
Deleting all Xamarin-related files from ~/Library/ and ~/Library/Caches
Turning off the related settings, then back on
Restarting my Mac
It may be worth noting that in the area above the text editor, I see the following 'no selection' message, no matter what I do in the file:
and if I select a symbol, the menu is always greyed out:
I have not seen anything that appears to be relevant in the IDE logs, and I have tried everything I can think of at this point.
Does anyone out there have any suggestions on what to try next, or how to debug this issue?
Lastly, on another Mac with the same version of Xamarin Studio, I am unable to reproduce, and we're both pulling from the same git repo.
Thanks in advance.

#jgoldberger was correct. Deleting <solution_name>.userprefs and re-opening Xamarin Studio has restored the functionality of the code completion and related features.
Thanks!

Related

Error The file 'Resources/LaunchScreen.xib' conflicts with 'Resources/LaunchScreen.xib'. ios xamarin

I am working with a Xamarin application where I have already built both IOS and Android applications. I am using Visual Studio 2019 for the development and use iPhoneSimulator to test the application, after connecting to the mac device. Suddenly I am getting an error as preceding.
Error The file 'Resources/LaunchScreen.xib' conflicts with 'Resources/LaunchScreen.xib'.
Anyone ever faced this issue before, I am 100% sure that it is not related to any recent code changes, thus providing codes wouldn't help here.
As I was sure that the issue is not related to the recent code changes. I did the preceding things first.
Clean the solution and rebuild
Delete the bin and obj folder manually and then rebuild
But I was getting the error again, the only thing which worked for me is restarting the visual studio and open the project again. Hope it helps.
I get this error a lot, or various other errors that seem to be related with items being duplicated. The easiest fix is to just disconnect from the Mac and reconnect. This is assuming that you are developing on a PC and pairing to a Mac. I suggested to the developers that they simply include disconnecting and reconnecting as part of the build process until they can figure out the actual cause.
If you are on the actual Mac, the process that Sibeesh Venu describes may be what occurs each time Xamarin pairs with the Mac.
The developers asked me, and others that have reported this issue, to turn on diagnostic debugging so that they can be provided with a log for when it happens. I did this, and noticed that it occurs less frequently for me. This makes me suspect that it's related to timing when files are processed.
https://github.com/xamarin/xamarin-macios/issues/6770#issuecomment-575310911
I encountered this same issue after after doing a merge in source control. It turns out that there was a duplicate instance of the .xib registration in my iOS.csproj file. In other words, there were duplicate lines that looked like this:
<InterfaceDefinition Include="Resources/LaunchScreen.xib.xib" />
Once I removed the duplicates, everything worked perfectly.

The "ResolveLibraryProjectImports" task failed unexpectedly

I have a Xamarin project, which is based on MvvmCross. The project is for both iOS and Android. I opened this project in Visual Studio 15. I got some errors, which I solved in no time. There are some errors, which are stuck and I couldn't solve them even after searching on Google and on Stackoverflow. I have tried each and every method found on Stackoverflow, but still all remaining errors are there.
This project is using 3rd party libraries like RestSharp and BoxApi.V2 (few more)
I am posting my error log below.
Severity Code Description Project File Line Suppression State
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'RestSharp(Android), Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'RestSharp(Android).dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() BoxApi.V2 (Android)
This error is repeating for all projects included in this solution. So I am getting this error multiple times.
I also want to add that the project was previously built on MAC and I am using windows, does this make some compatibility or cross OS issue?
I have checked all assembly references and all are working fine.
I've literally just had this with a brand new Xamarin.Forms application in Visual Studio 2017.
The root cause appears to be that I let VS2017 create the project in it's default location 'C:\Users\Dave\Documents\Visual Studio 2017\Projects' and this has resulted in one of more files now having a path which it too long.
I moved the solution to the root of my D drive and it builds without any problem.
Your issue is most likely linked to this post on the Xamarin forums, and this bugzilla entry. Without a reproducible sample, all I can advise you try is:
Updating Xamarin for Visual Studio, Xamarin.Android, and Xamarin.iOS
to the latest stable versions
Cleaning and rebuilding
Deleting all of the bin and obj folders from your project directories
Restarting Visual Studio/your PC
Failing all of that, there's not likely to be anyone who can help you without a reproducible sample and potentially your Xamarin logs.
edit your android project file (csproj) like below
this issue topic may guide https://github.com/xamarin/AndroidSupportComponents/issues/51
Had same problem. Here is my solution
Restart Visual Studio
Open the Project
Clean the solution
Rebuild the solution
Close solution
Reopen the project
I'm working with XAML (.xaml) and code-behind file (.xaml.cs). My issue was that I had the same page name, but under different namespaces. The XAML and the code behind file didn't match together. So finally it was an issue with my XAML, because of course it couldn't find the view element.
Well for me the problem was in my xaml file...
Somehow while setting the Layout bounds i used '.' as a separator instead of ','
e.g
AbsoluteLayout.LayoutBounds="0.5.0.3,1,0.3" should have been AbsoluteLayout.LayoutBounds="0.5,0.3,1,0.3"
Hence changing the '.' to ',' solved the problem
This happened to me when I accidentally installed nuget packages in a class library that was included in the solution. I just had to uninstall the packages from the class library project.
In my case, this issue came with another related to my xaml.
I had to solved the second in order this error dissapear. I clean up the class with a new default content and then clean all projects and solution. By last, close visual studio, open it , run the project and It works know .-.
This is still a fresh problem, after all attempts i wanted to try to shift the code to a shorter path - however that is lot of work as svn management will get complicated, so i wanted to first verify if path is really an issue, one way to do this was to check where the android SDKs are stored. I am on mac and the investigation revealed that SDKs path was longer than my project path. Plus i tried with a fresh project, and that was compiling correctly.
So i dropped the idea of shifting. Instead i used svn and compared what has changed since last correct build.
The comparison revealed that the project file of droid was somehow referring to the project file of iOS, it seems like some bug of Visual Studio. So i reverted the changes and than all got back to normal.
i get the same error and i usually solve this by closing all other opened xamarin solutions and there is one more way i had solved this issue -> go to taskmanager and find MSBUILD Service and end that service -> clean your solution -> Rebuild
We have encountered this too, it appears to be some type of race condition when building multiple projects and a very deep/complex dependency tree (our example has over 100 projects).
The only way we've been able to resolve this (beyond continually rebuilding) is to disable Visual Studio 2017's Parallel Build Abilities (Tools->Options->Projects and Solutions->Build and Run->"1" Maximum number of parallel project builds).
The problem appears to be in ResolveLibraryProjectImports.cs (https://github.com/xamarin/xamarin-android/blob/93ddf96f86710ad848d5189858567dd7fe964579/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs) there is most likely a race condition with their logic to shorten up the file names.
There are zero tests around this which means there is most likely some dodgy code.
I am going to attempt to dig more and get an issue opened up on GitHub but finding a reliable repo is probably going to be very difficult.
This worked for me:
Clean solution
Build one project at a time starting at the top - NOT rebuild solution - just one project at a time
Try deleting the contents of Obj and bin folder as well
When done delete the project from the emulator or device before you run it again
Hope this helps.
Still have issues ? Check your namespaces and your xaml code. Sometimes when you copy/paste some files, it can be the problem.
Not sure if it will help anyone of you. For my case, I comment the erroneous class (eg. those with missing references), and it will start to pick up everything and build again.
In my case, I just forgot to delete the clicked event in XAML that doesn't exist in my code behind(cs file). After that, I just clean and rebuild.
I think that error was caused by not updated references.
It's probably an issue with your references / reference assemblies?
If you look under each project's references folder in the solution explorer, any references that visual studio cannot find, delete and re-add them (right click reference folder to add).
I have Faced this issue a thousand times its actually a very simple thing when you create a new project visual studio creates it in C:Drive in its default folder all you have to do is move your project out in some other Drive Like D:, E: whatever just make sure to keep it in the root of your Drive i.e. If you move it in D: Then place it like this D/Project/solutionFile
Here is the problem:
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Try to move you project to another location like "C:/" , or change the name of the project for something more brief
I encountered the same issue and none of the solutions above worked. After noticing and error on the list regarding Cryptography I knew it had to be related to FIPS being enabled (required by a VPN client)
By disabling FIPS and restarting Visual Studio the issue was resolved.
I had this error as well. In my situation it was accompanied by Xamarin.Forms.Maps not importing into the one of the xaml.g.cs files correctly. I had all the using statements correct. The IDE was showing no errors but it kept telling me that Xamarin.Forms did not have a name space Map. It was generating in MapPage.xaml.g.cs as Xamarin.Forms.Map instead of Xamarin.Forms.Maps.Map and I couldn't force a fix manually. It turned out though that the suggested xmlns:maps for maps was causing the problem. The IDE had told me to use "http://xamarin.com/schemas/2014/forms" but the correct namespace is "clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps". After I changed this it was able to build my App1.dll
This was how I got the error. In a StackLayout I put in a Padding property, and I seperated the 4 digits by a space rather than a comma.
To find the bug I had to comment out the XAML controls individually and rebuild to isolate where the error is, and eventually I found the problem line.
So basically this was the error message I got for a syntax error in my XAML code!
In any other language I would expect to be informed what the error is so I can fix it in seconds. But this took me a few hours - although next time I know what to do.
This kind of issue may also come if by mistake you have any syntactical error like in my case: two text cells were present in the ListView -
<ListView x:Name="ProductsView">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding ProductId}" />
<TextCell Text="{Binding ProductDescription}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I went through other posts for this issue and found the same issue occurred due to the presence of syntactical errors, which VS doesn't report directly. So look for this, otherwise, reinstall the compatible version of xamarin.forms -> clean solutions -> rebuild by reopening VS.
I have faced the same problem today. After two days searching, I have found the solution here. The issue is Xamarin.Forms library does not install all its dependent Nuget packages while first creating project by choosing cross-platform Mobile(Xamarin.Forms) project template from Visual Studio 2017. I have to manually install the upgraded dependent nuget packages to build the project successfully. Also have removed and added Xamarin.Forms at the end which resolves the issue.
Also, it is some time creating issues when two instances of Visual Studio 2017 is running, make sure only one instance is only running as I have encountered this issue as well.
xmlns:maps="clr-namespace:Xamarin.Forms.Maps; assembly=Xamarin.Forms.Maps"
The problem was because of the space between the semicolon above and the assembly as stated above. As soon as the gap is closed, it compiles.
Shorteninig the path(folder names) to the solution solved it for me.
For example : the path was :
C:\Users\Username\Downloads\Compressed\ListView-GettingStarted-in-Xamarin-Forms-master\ListView-GettingStarted-in-Xamarin-Forms-master\GettingStarted
and i changed it to :
C:\Users\HelloKali\Downloads\Compressed\3\2\1.

Xamarin for Visual Studio 2015 Portable Forms need to "retouch" MainPAge.xaml to avoid errors

sorry if this questions been asked already, I suspect it's quite common..
I'm using Xamarin for Visual Studio 2015 (4.0.3.214), and a common thing is that every now and again after saving or loading the project all the variables associated with the MainPage.xaml file are red, i.e. showing up as errors in the solution error list.
By retouching - saving the file after an edit (like adding a space then doing a backspace so nothing changes), the errors go away.
Which suggests a problem with the way Xamarin handles the build process and keeps track of auto-generated files. Is there a solution or a fix to this, or even a proper explanation ?

Visual Studio C# IntelliSense not automatically displaying

Just recently, my Visual Studio 2010 stopped displaying IntelliSense suggestions automatically while I am typing. I can still press ctrl+space to get it to work, but it doesn't automatically show a list of suggestions like it used to. I have already tried disabling all my extensions, restarting VS and the computer, and I have checked all the appropriate settings (Options -> Text Editor -> C# -> IntelliSense) to make sure that it is set to offer suggestions after a character is typed.
Has anyone seen this behavior before? Does anyone have any other suggestions for how I can get IntelliSense to go back to the way things were before? If not, I might just have to do a fresh reinstall of VS...
In prose, in case you can't see the above image:
Open Tools > Options > Text Editor. If you're only having this issue with one language, find that language; if it's for everything, click "All Languages". Right at the top, there'll be a few options labeled "Auto list members", "Hide advanced members", and "Parameter information". Make sure all of those are enabled (though the second may be disabled; if so, ignore it).
I have found that at times even verifying the settings under Options --> Statement Completion (the answer above) doesn't work. In this case, saving and restarting Visual Studio will re-enable Intellisense.
Finally, this link has a list of other ways to troubleshoot Intellisense, broken down by language (for more specific errors).
http://msdn.microsoft.com/en-us/library/vstudio/ecfczya1(v=vs.100).aspx
I'll start off my noting that this hasn't happened since I upgraded my RAM. I was at 4GB and would often have multiple instances of VS open along with SSMS. I have since gone to 8GB and then 16GB.
Here's the steps I go through when I lose intellisense.
If only one file/window appears to be affected, close/reopen that file. If that doesn't work, try below.
In Visual Studio:
Click Tools->Options->Text Editor->All Languages->General
Uncheck "Auto list members"
Uncheck "Parameter information"
Check "Auto list members" (yes, the one you just unchecked)
Check "Parameter information" (again, the one you just unchecked)
Click OK
If this doesn't work, here's a few more steps to try:
Close all VS documents and reopen
If still not working, close/reopen solution
If still not working, restart VS.
For C++ projects:
MSDN has a few things to try: MSDN suggestions
The corrupt .ncb file seems most likely.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Notes:
This issue does not appear to be specific to C# as C++ and VB users
report the same issue
Tested in VS 2013/2015
Steps to fix are:
Tools
Import and Export Settings
Reset all settings
Back up your config
Select your environment settings and finish
I also faced the same issue but in VS2013.
I did the below way to fix, It was worked fine.
Close all the opened Visual studio instance.
Then, go to "Developer command prompt" from visual studio tools,
Type it as devenv.exe /resetuserdata
Restart the machine, Open the Visual studio then It will ask you to choose the development settings from initial onwards, thereafter open any solution/project. You'll be amazed.
Hope, it might helps you :)
Deleted the .suo file in solution folder to solve the problem.
Sometimes i've found Intellisense to be slow. Hit the . and wait for a minute and see if it appears after a delay. If so, then I believe there may be a cache that can be deleted to get it to rescan.
I hit this today after the following sequence:
Added a new class to my project.
Closed Visual Studio, but accidentally selected No when it asked if I wanted to save changes.
Reopened Visual Studio, and found that it reopened the new file automatically but without my previous changes (as expected). However, IntelliSense was no longer working in the new file.
The problem was in addition to not saving changes to the new file, it didn't save changes to the project, so after reopening Visual Studio the file was not part of the project. The Show All Files command in Solution Explorer, or Add → Existing Item..., resolved the problem.
I had the file excluded from the project so i was not able to debug and have intellisense on that file.
Including the file back into the project solved my problem! :)
A new cause for this in the .net core era is having a project loaded for an unsupported .net core version. For instance if you loaded a project from GitHub that was set to use:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
But you only have 2.1 installed or find yourself using Visual Studio 2017 then the compiler wont be able to find the SDK code and thus provide intellisense.
The solution in that case might be to right click on your project and select Edit MyProject.csproj from the context menu and change the target framework as necessary:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
This assumes whatever project you loaded can actually be run under a lesser target framework.
I simply closed all pages of visual studio and reopened ..it worked.
Deleting the .vs folder in the solution solved my issue. You have to exit from Visual Studio and then delete the .vs folder and start Visual Studio again.
Closed all my VS windows
Started the Visual Studio Installer and clicked 'Modify'.
Under 'Individual components' > 'Code Tools' > Deselected NuGet package manager and re-selected it.
After modifying and restarting VS, IntelliSense was working correctly again.
Found my answer on https://developercommunity.visualstudio.com/content/problem/130597/unity-intellisense-not-working-after-creating-new-1.html
[Tools -> Options -> Text Editor -> All Languages -> CodeLens]
Check if check box "Enable CodeLens" is checked
I have just come to about this problem while installing one of the extensions and its file was deleted by my anti virus so I just disabled my anti virus and reinstalled visual studio. Suggestions are working properly without any changes made after installation.
At the bottommost right look at the blue line where Ln, Col, Spaces, UTF, CRLF,..... here the language is specified.
Check that your language and the language specified there are the same.
In my case, it was Django Python while I was trying to use HTML.
This may be due to the solution configuration changed to Release Mode instead of debug. Right click on solution -> Properties -> Configuration Properties -> Set Configuration To Debug if it is in Release.

Intellisense doesn't work for one particular project in VS2010

Thanks in advance.
This problem has killed one whole day of my time.
Intellisense in Visual Studio 2010 works on all projects in my solution except one. It used to work until yesterday and today it just doesn't work particularly for that single project. Can anyone suggest a workaround for this?
Things I tried: deleted the .ncb file, restarted VS 2010, restarted PC, checked in tools->options-texteditor->c# and General settings to enable suggestions. But none of these steps helped me.
regards
Yash
Does the same thing happen on a different pc in the same solution?
If it does, try adding the same files to a new project and see what happens?
I experienced a similar problem after editing some code when running the debugger. What I did was exit debugging mode, restart VS 2010 and Rebuild Solution. Hope it helps
Try to run VS 2010 in safe mode.
If Safe Mode does not help at all, go to Tools > Options..., click Text Editor to collapse, then click All languages. Under Statement completion, make sure you check (tick) them all.
Update: You can also try resetting your VS 2010 settings
I don't know if this will help anyone but I got the problem to resolve by deleting the ncb file AND the suo file. After that (In VS 2008) the Statement completion option as described by eibhrum had one grayed out box (checked) and the Display option had all boxes grayed out (and checked). I checked them all.
I tried checking just the statement options (prior to my deletion of both the ncb and suo files) and that did not work. I never tried checking the display options before during my last two hours of multiple attempts to resolve this issue (I like 'Yash' had one project that did not work; yet resetting that project back to the cpp and h file it had yesterday when it worked did not resolve the problem).
I think (note think) that deleting the suo file is a hard reset your settings option.
In the end I don't understand why the problem arises so its a damn frustrating trial and error. Maybe my approach will help someone out there. Its certainly a very common problem!

Categories