I am really eager to get started with MvvmCross - it looks like a very promising framework for cross-platform solutions. Anyway, I am having a build error as I'm going through the tutorial, https://github.com/slodge/MvvmCross/wiki/Tutorial-Part-1. The error arises in building the Android project component. This is the error:
Error 1 The type 'Android.App.Activity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'. C:\Users\Steven\documents\visual studio 2010\Projects\Tutorial\Tutorial.UI.Droid\Views\MainMenuView.cs
I saw some similar questions posted (Portable Class Library strong assembly reference problems in MonoTouch/MonoDroid) and followed the suggested solutions but without success. This was in VS2012, so I tried it in VS2010 and encountered the same problem. Has anyone come across this error? The PCL portion (Tutorial.Core) builds fine on its own. I checked the PCL csproj file and saw it is using Profile 104 and I did already create the MonoAndroid xml file that sits in that directory:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks\MonoAndroid,Version=v1.6+.xml
The reference for Mono.Android in the Tutorial.UI.Droid project appears to be fine. The path for the dll is C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll and VS reports Resolved=True and Strong Name=True for this reference.
Any help would be greatly appreciated.
Your problem has nothing to do with PCL. Starting version 4.2, Mono for Android assemblies are strong-named i.e. assemblies shipped by Xamarin will be signed with a Xamarin key. Earlier the assemblies were either not signed or only delay-signed. This change affects the strongnames of some Xamarin assemblies.
Like in your case, it is asking you to add reference to:
Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd
which is strong-named. At present you'd be using:
Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
which is not strong-named.
So all you need to do is re-build all your assemblies (in MVVMCross as well as any other projects you may have) that refer Mono.Android with the new strong-named assembly.
That should fix your problem.
Related
I have a WinForms application using .NET Framework 4.7.2, which uses a library that targets NetStandard2.0 and 2.1. While the library does seem to load, I get an exception when the library is called, saying "Error could not find assembly netstandard2.1 file not found". I assume that I need to add a reference from the application to NetStandard2.1. Is that correct? How do I do this?
I am playing with .NET Standard and found strange that if I have the following project.json specified for both a .NET Core class library (xproj) and a Portable Class Library (csharp), only the latter can be properly referenced from a Xamarin.Android project:
{
"supports": {},
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
"frameworks": {
"netstandard1.4": {}
}
}
I can add both as a reference, dotnet update works as expected (or at least no error messages shown), but the .NET core library is not realized:
type or namespace could not be found
I find this strange, since I'd expect any .NET standard targeting library to work properly. Am I doing something wrong or intentionally only PCLs are supported from Xamarin?
I assume you have a .csproj for the Xamarin.Android project and an .xproj for your .NET Core class library, which is targeting .NET Standard.
I believe the issue might be because of the different project systems we currently have and where each of them expects to find built assemblies for project references.
A workaround is to manually edit the .csproj to include the reference with the correct hint path. For example:
<Reference Include="SomeOtherClassLibrary">
<HintPath>..\SomeOtherClassLibrary\bin\$(Configuration)\netstandard1.6\SomeOtherClassLibrary.dll</HintPath>
</Reference>
You may also need to manually add a build dependency from the Xamarin.Android to the class library project to ensure the projects are built in the correct order (right click the Xamarin.Android project in Solution Explorer Build Dependencies > Project Dependencies...).
In summary, it's not that .NET Standard targeted libraries don't work with Xamarin, or that Xamarin only supports PCLs. It's a quirk with project references and the current state of the tooling, which I am sure will improve in time.
We are developing a framework on top of Protractor/Selenium framework. Our projects are all C# signed projects. So, we need to reference signed Protractor and Selenium dlls.
I used the signed WebDriver.dll and Webdriver.Support.dll (version 2.46) from here.
But, when I compile my project, I am getting the below error -
"The type 'OpenQA.Selenium.Internal.IWrapsDriver' is defined in an assembly that is not referenced. You must add a reference to assembly 'WebDriver, Version=2.46.0.0, Culture=neutral, PublicKeyToken=null'."
How can I address this error and get my code running?
I've been playing around with the Starter Edition of Xamarin Studio to determine if it will meet my needs. I understand (so I thought) the limitations of this edition; 32K compiled IL limit, no native libraries, etc. Now, I understand native libraries to be C/C++ libraries, or even native Java libraries. This does not seem to be the case.
I have a solution in Xamarin Studio with 2 projects. One is an Android Class Library, the other is an Android Application. When I reference the class library from the application project and build, I get the following error.
Your app references native libraries. This functionality requires Indie Edition or higher.
I beg to differ! Every .cs file in the referenced Android class library project is simple .NET code. What am I missing? I can successfully run the Tasky Android_Starter solution without issue, and it is made up of 2 projects like mine.
I had to delete the Resources folder and manually edit the Android class library project file in order to get this working. I looked at the Tasky sample's project file as a reference.
After deleting the auto-included Resources folder from the project, edit the .csproj file in a text editor to remove the following XML elements:
Project\ProjectGroup\AndroidResgenFile
Project\ProjectGroup\AndroidResgenClass
With those things taken care of, I no longer get the error. I'm guessing, Xamarin Studio thought I was referencing another Android application instead of a class library. Not sure why the default project template includes things to break such a flow, but perhaps I'm not "doing" right" either. Go figure.
Deleting the Resources folder and manually editing the csproj file didn't work for me. I had to create a new C# Library project instead of creating an Android Library Project and import my .cs files into that. After that it compiled and ran fine.
I am working on a project with MVC4, and have decided that I wish to add some dependency injection via Ninject. After download/install via NuGet, I find this error in the NinjectWebCommon.cs (Line 23):
The type 'System.Web.IHttpModule' is defined in an assembly
that is not referenced. You must add a reference to assembly
'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
and then a bit later (line 44):
The type or namespace name 'IHttpModule' could not be found
(are you missing a using directive or an assembly reference?)
I expect that this Normally works, but that I've done something that doesn't work when adding Ninject to the project after the fact.
Edit: The above errors are only thrown by the test project....
Make sure you specify the System.Web reference in both the main and test project. The test projects have their own list of references to maintain. I expect you don't have System.Web in the test project.
Make sure Ninject didn't add web references to your model project.