why_vincent
why_vincent

Reputation: 2262

Dependency issue with Xamarin

I'm having some dependency issues with Xamarin Studio. I have a dependency to FreshEssentials and during runtime, when trying to use components from that package, I receive this error: "Could not load file or assembly 'FreshEssentials' or one of its dependencies". I have been using FreshEssentials for a while and it has worked out great. This error came all of a sudden and I do not know why.

I have done the following:

Build->Clean All.
Build->Rebuild All.
Project->Update NuGet Packages(gives me the error 'Could not update packages.').
Project->Restore NuGet Packages.
Project->Add NuGet Packages, added FreshEssentials again.
Restarted the IDE.

These procedures do not help. Sorry for formatting my actions as code, SO won't let me post it if I don't.

The problem occurs when I am running my App on the iOS simulator.

I'm hoping that someone here has had a similar problem and might have some advice.

Edit:

I just noticed that my tests won't execute, giving me this StackTrace. I'm guessing it is also dependency related. This is after having removed all packages in Xamarin Studio and added them again suing NuGet->Add NuGet Packages.

One or more errors occurred.
Stack trace:
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) [0x00014] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2157 
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) [0x00034] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:562 
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x00000] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:532 
  at MonoDevelop.UnitTesting.NUnit.NUnitAssemblyTestSuite.RunUnitTest (MonoDevelop.UnitTesting.UnitTest test, System.String suiteName, System.String pathName, System.String testName, MonoDevelop.UnitTesting.TestContext testContext) [0x0014a] in /Users/builder/data/lanes/3541/a6f7a24a/source/monodevelop/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitAssemblyTestSuite.cs:424

Upvotes: 1

Views: 307

Answers (1)

Ian
Ian

Reputation: 60

I've experienced a similar issue where only the iOS project would throw me that very same exception.

It looks like the iOS linker doesn't include the assembly unless there is an explicit reference to it from within the iOS project.

Inside the iOS project main.cs try adding the following to the Main function:

var dummyObject = new FreshEssentials.ListViewItemTappedAttached();

This resulted in the following function for me:

    static void Main(string[] args)
    {
        var dummyObject = new FreshEssentials.ListViewItemTappedAttached();

        // if you want to use a different Application Delegate class from "AppDelegate"
        // you can specify it here.
        UIApplication.Main(args, null, "AppDelegate");
    }

Hope this helps!

Upvotes: 3

Related Questions