Xamarin.Studio not recognizing References or Usings?

SFurlaniSFurlani USMember

Hello,

I have this issue every time I open Xamarin.Studio. The syntax highlighting, autocomplete, and right-click menu does recognize any references or usings in my files.

image

Exceptions: Current File's Namespace, Compiles fine.

The only thing I can do to get it to go away, is to "reference" Mono.Android - even though it already exists in the references. (I've removed and re-added it).

Any assistance is appreciated. No one else in my office seems to get this issue.

Thanks,

Best Answer

Answers

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Can you build?

  • SKallSKall USMember ✭✭✭✭

    Do you have other targets types (f.e. iOS) in the same solution? I had similar behaviour when XS or VS thinks the target is other than Android.

  • SFurlaniSFurlani USMember

    Yes I can build, and no I don't have any other targets in the solution.

  • SFurlaniSFurlani USMember

    It happens with New Solutions for Android & ASP.Net, but not for a C# Console Project, Gtk App, or C# NUnit suite.

    I found it odd that the ASP.NET App would want to reference Mono.Android...

    HTH

    image
    image

  • mhutchmhutch USMember, Xamarin Team Xamurai

    The issue with the "Resolve" command suggesting assemblies from other frameworks is fixed in the next release.

    The issue with all types not being resolves is very strange and not once we've seen before. Maybe our code completion expert @MikeKrger would have to ideas about how to debug it.

    My best guess is that it's a corrupted type info cache. Cold you try deleting AppData\Local\XamarinStudio-4.0\Cache ?

  • MikeKrgerMikeKrger DEXamarin Team, Beta Xamurai

    It's nothing with the type info cache - it can't corrupt that way anymore.

    My guess is that the project system gives wrong infos (that's why it's related to the project type) - do you've exceptions in the log ?

  • SFurlaniSFurlani USMember

    @MikeKrger, what log should I be looking in? There are no exceptions when building or opening the project file.

    @mhutch I deleted the cache, no improvement.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Help -> Open Log Directory, then check the most recent Ide log.

  • SFurlaniSFurlani USMember

    @mhutch @MikeKrger Oh my... LOTS of stuff in the logs. I've attached my two most recent IDE Logs.

    I'm not sure what's relevant. It looks like a Package Not Installed and Method Not Found errors being thrown.

    HTH,

  • MikeKrgerMikeKrger DEXamarin Team, Beta Xamurai

    What happens after you recompile the project ? As far as I remember the android projects are a bit ... strange when looking up references before you compile them.

    Does a recompile fix the errors ?

  • MikeKrgerMikeKrger DEXamarin Team, Beta Xamurai

    The logs where helpful - I think that's the problem:

        ERROR [2013-08-06 11:41:19Z]: Error while reloading all references of project:MonoDevelop.MonoDroid.MonoDroidProject
        System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Serialization.SerializationException: Member 'hasBeenLogged' was not found.
           at System.Runtime.Serialization.SerializationInfo.GetElement(String name, Type& foundType)
           at System.Runtime.Serialization.SerializationInfo.GetBoolean(String name)
           at Microsoft.Build.BuildEngine.InvalidProjectFileException..ctor(SerializationInfo info, StreamingContext context)
           --- End of inner exception stack trace ---
    
        Server stack trace: 
           at System.RuntimeMethodHandle.SerializationInvoke(IRuntimeMethodInfo method, Object target, SerializationInfo info, StreamingContext& context)
           at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
           at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
           at System.Runtime.Serialization.ObjectManager.DoFixups()
           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
           at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
           at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
           at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
    
  • MikeKrgerMikeKrger DEXamarin Team, Beta Xamurai
  • mhutchmhutch USMember, Xamarin Team Xamurai

    Are you using the Mono runtime?

  • SFurlaniSFurlani USMember

    @mhutch ah, no? When I compile against mono it gives me this:
    D:\SVN\trunk\Core\Source\MCC.Core.csproj: Error: D:\SVN\ahlta-t_mcc\MCC\MCC\trunk\Core\Source\MCC.Core.csproj: C:\Program Files (x86)\Mono-2.10.9\lib\mono\xbuild\Novell\Novell.MonoDroid.CSharp.targets: Project file could not be imported, it was being imported by D:\SVN\trunk\Core\Source\MCC.Core.csproj: Imported project: "C:\Program Files (x86)\Mono-2.10.9\lib\mono\xbuild\Novell\Novell.MonoDroid.CSharp.targets" does not exist. (MCC.Core)

  • mhutchmhutch USMember, Xamarin Team Xamurai
    edited August 2013

    No, you shouldn't use the Mono target runtime, it's not a supported build system for Xamarin.Android on Windows. But it would have explained your symptoms.

  • SFurlaniSFurlani USMember

    @MikeKrger - No, a rebuild doesn't fix the issue. The only way is to Right-Click --> Resolve and then remove whatever code was added in.

    @mhutch - OK.

    Thanks,

  • mhutchmhutch USMember, Xamarin Team Xamurai

    It looks like Xamarin Studio and the builder process are somehow running on different runtime versions and information cannot be serialized between them.

    Can you please attach full version information from the About box details?

  • SFurlaniSFurlani USMember

    Odd,

    === Xamarin Studio ===

    Version 4.0.10 (build 7)

    Installation UUID: 9a31e048-5698-47b3-92cb-0b92fd465a9f

    Runtime:

    Microsoft .NET 4.0.30319.18052
    
    GTK 2.24.13
    
    GTK# (2.12.0.0)
    

    === Xamarin.Android ===

    Version: 4.8.0 (Business Edition)

    Android SDK: C:\Users\sfurlani\AppData\Local\Android\android-sdk

    Supported Android versions:
    
        2.1   (API level 7)
    
        2.2   (API level 8)
    
        2.3   (API level 10)
    
        3.1   (API level 12)
    
        4.0   (API level 14)
    
        4.0.3 (API level 15)
    
        4.2   (API level 17)
    

    Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31

    java version "1.6.0_31"

    Java(TM) SE Runtime Environment (build 1.6.0_31-b05)

    Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

    === Build Information ===

    Release ID: 400100007

    f324e2154ee86ae1b6b8483392eddbf418e6381b

    Build date: 2013-07-20 02:59:47Z

    Xamarin addins: fe4f180e2386eafc00087ef68c3a580cff4a2592

    === Operating System ===

    Windows 6.1.7601.65536 (64-bit)

    It wouldn't let me copy the loaded assemblies - hope this is enough.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Yes, that's what I needed. The only thing that looked unusual is that the .NET version is 4.0.30319.18052 whereas mine is 4.0.30319.18051, but it looks like that's just a security update for versions of Windows earlier than than Windows 8.

    I think we may be focusing on the wrong thing here - the serialization error with InvalidProjectFileException is indeed an bug, but it's only a problem because the exception is being thrown in the first place.

    Basically, it looks like the MSBuild engine doesn't like your csproj file for some reason.

    Do you perhaps have merge conflicts in the file or something?

  • SFurlaniSFurlani USMember

    We've had a ton of merge conflicts in the csproj over the course of this project, but no one else is seeing the issue I am.

  • mhutchmhutch USMember, Xamarin Team Xamurai
    edited August 2013

    Right, merge conflicts would be local to your machine.

    Can you share the csproj file with us?

  • SFurlaniSFurlani USMember
    edited August 2013

    Sure, there's nothing proprietary or secret in it.

    **Edit, wouldn't let me post it. Let me try emailing it?

  • mhutchmhutch USMember, Xamarin Team Xamurai

    I tried opening the solution but it opened successfully in both XS and VS.

    Could you please use Process Explorer as admin to inspect the assemblies loaded by Xamarin Studio and the MonoDevelop MSBuild builder, as shown in the attached screenshot?

  • SFurlaniSFurlani USMember

    @mhutch This is what Process Explorer is giving me.

    I honestly don't know what I'm looking for here, but the image numbers and the versions all look to be the same?

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Thanks, that's the information I was looking for and it all looks correct.

    Are you able to build your solution from the commandline using MSBuild.exe?

  • SFurlaniSFurlani USMember

    @mhutch yes I can build it from the command line. Log attached. 0 warnings, 0 errors. I can build it from within Xamarin.Studio - just the intellisense shows everything as red until I resolve.

    log.txt 321.3K
  • SFurlaniSFurlani USMember

    Hey, I just updated to 4.0.12 build 3 and everything is working now!

    === Xamarin Studio ===

    Version 4.0.12 (build 3)

    Installation UUID: 9a31e048-5698-47b3-92cb-0b92fd465a9f

    Runtime:

    Microsoft .NET 4.0.30319.18052
    
    GTK 2.24.13
    
    GTK# (2.12.0.0)
    

    === Xamarin.Android ===

    Version: 4.8.0 (Business Edition)

    Android SDK: C:\Users\sfurlani\AppData\Local\Android\android-sdk

    Supported Android versions:
    
        2.1   (API level 7)
    
        2.2   (API level 8)
    
        2.3   (API level 10)
    
        3.1   (API level 12)
    
        4.0   (API level 14)
    
        4.0.3 (API level 15)
    
        4.2   (API level 17)
    

    Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31

    java version "1.6.0_31"

    Java(TM) SE Runtime Environment (build 1.6.0_31-b05)

    Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

    === Build Information ===

    Release ID: 400120003

    593d7acb1cb78ceeeb482d5133cf1fe514467e39

    Build date: 2013-08-07 18:31:48Z

    Xamarin addins: 25a0858b281923e666b09259ad4746b774e0a873

    === Operating System ===

    Windows 6.1.7601.65536 (64-bit)

  • SFurlaniSFurlani USMember

    Me too. I'm glad it works and hopefully this helps if it happens again.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    Awesome, glad it's working for you guys now!

Sign In or Register to comment.