I am just a newbie in Xamarin, so I tried creating the simple Phoneword application available at Xamarin on-line guides.
The solution created in Visual Studio comprises 4 distinct Projects:
This is how the solution structure looks like:
Now inside the first project an interface has been declared:
namespace Phoneword
{
public interface IDialer
{
bool Dial(string number);
}
}
I now try to use this interface from within the UWP project:
using Phoneword.UWP;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Windows.UI.Popups;
using Xamarin.Forms;
[assembly: Dependency(typeof(PhoneDialer))]
namespace Phoneword.UWP
{
public class PhoneDialer : IDialer
{
...
Building the solution ends successfully. But when I try to Deploy the UWP project I get this error:
The type or namespace name 'IDialer' could not be found (are you missing a using directive or an assembly reference?)
Can anyone give me hint on what could be the source of this error?
Update
There was one more error I was getting when I tried to deploy:
Error DEP0700: Registration of the app failed. [0x80070005] error 0x80070005: Opening file from location: AppxManifest.xml failed with error: Access is denied.
I closed the solution, exited Visual Studio started and loaded again and the first error disappeared. So, it seems, there is nothing wrong in consuming an interface, declared in the Code Sharing Project, from within the UWP Project.
The actual error I was getting was due to access rights restrictions of the folder were the project was being deployed.
You are not referencing the Phoneword
in your PhoneDialer.cs
file. Add this to the top:
using Phoneword; // <== Add this
using Phoneword.UWP;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Windows.UI.Popups;
using Xamarin.Forms;
I had a similar issue. The way to fix it is just to restart Visual Studio or reload the solution.
I had the same problem, Add this to your code at the top
using static Phoneword.MainPage;
and it should work fine The reason it was not working is because you didn't have a reference to it. For some reason the Assets that you import for that course do not have this reference in it.
Had the same problem. You need to right click on the Phoneword project in the Solution Explorer and click build to build it on it's own.
Then add the using statement for the Phoneword project to your PhoneDialer file.
The reference to IDialer then becomes available.
User contributions licensed under CC BY-SA 3.0