최신 Xamarin Alpha가 설치되어 있으며 UWP 및 DependencyService가 작동하지 않습니다. UWP 프로젝트에서 Xamarin.Forms DependencyService Get() 메서드가 PCL에서 Null을 반환합니다.
나는이 :Forms.Init(e);
// For release version, doc said debug will do this itself
DependencyService.Register<SpecialInterface>();
IInterface1 iinterface1 = DependencyService.Get<IInterface1>();
이 인터페이스 포인터를 찾을 수 없습니다. PCL에서
나는이 : 그것은 UWP와 안드로이드 모두에서Get<IInterface1>()
호출의
null
값을 반환 실패 PCL에 포함 된 뷰 모델에서
IInterface1 iinterface1 = DependencyService.Get<IInterface1>();
(버튼 클릭 후). 다음과 같이
using PrismUnityApp2.UWP;
using SharedProject1;
using Xamarin.Forms;
[assembly: Dependency(typeof(SpecialInterface))]
namespace PrismUnityApp2.UWP
{
public class SpecialInterface : IInterface1
{
public SpecialInterface() { }
public int TestMethod(int i)
{
return i;
}
}
}
마지막으로, 인터페이스가 공유 프로젝트에 정의되어 있습니다 :
namespace SharedProject1
{
internal interface IInterface1
{
int TestMethod(int i);
}
}
내가 샘플 "UsingDependencyService"에서 작업이 여기에
는 UWP 프로젝트에 포함 된 구현 Android의 경우 HyperV가 꺼져있어 WinPhone이 실패합니다.무엇이 누락 되었습니까?
도움 주셔서 감사합니다.
사용하여 다음 패키지/버전 :
- Prism.Unity.Forms 6.2.0.pre4
- Prism.Forms 6.1.0.pre4
- Xamarin.Forms 2.2.0.45
- 유니티 4.0.1
윈도우 10 UWP
public void OnNavigatedTo(NavigationParameters parameters) { if (parameters.ContainsKey("title")) Title = (string) parameters["title"] + " and Prism"; IInterface1 iinterface1 = DependencyService.Get<IInterface1>(); if (iinterface1 != null) { int value = iinterface1.TestMethod(1); Title += " ::: " + value; } }
인터페이스를 공개로 설정해보십시오. –
쉽게 해결할 수 있었지만 내부를 공개로 바꿨으나 여전히 실패합니다. 나는 오늘 그것을 다시 보게 될 것이므로 뭔가 찾을 수 있습니다. –
등록 메소드 호출이 필요하지 않아야 속성이 충분합니다. DependencyService.Get 및 클릭 처리로 코드를 게시 할 수 있습니까? –