xamarin-docs
xamarin-docs copied to clipboard
System.InvalidCastException: 'Specified cast is not valid.
Hi,
I have tried a Xamarin.ios Bindings to create a nuget using a iOS SDK with Objective-c. I create a API definition file using sharpie tool. Then i introduce some implementation with methods as well. In the one of method I am getting the error "System.InvalidCastException: 'Specified cast is not valid.". So for that i would like to change whether ApiDefintion file is correct or not. And Here I attached the inheritance diagram is reference from right to Left. Kindly please help me to solve this issues.
NSObject <========= ProtectionPolicy <======= PasswordPolicy <======= BiometricPolicy
For example:
[Protocol]
[BaseType(typeof(NSObject))]
interface ProtectionPolicy
{
[Abstract]
[Export("policyId")]
Identifier PolicyId { get; }
[Abstract]
[Export("policyType")]
PolicyType PolicyType { get; } // This is Enum (three option)
}
[Protocol]
[BaseType(typeof(NSObject))]
interface PasswordPolicy : ProtectionPolicy
{
.........
}
[Protocol]
[BaseType(typeof(NSObject))]
interface BiometricPolicy : PasswordPolicy
{
[Abstract]
[Export("enableAuthentication:error:")]
bool EnableAuthentication(string password, out NSError error);
[Abstract]
[Export("getAuthenticationState")]
AuthenticationState AuthenticationState { get; } // This is Enum (Three option)
}
[Protocol] interface Container { [Abstract] [Export("getName")] string Name { get; }
[Abstract]
[Export("getUserId")]
string UserId { get; }
[Abstract]
[Export("getPolicy:")]
IProtectionPolicy GetPolicy(out NSError error); // Reference IProtectionPolicy
[Abstract]
[Export("getDate:")]
NSDate GetDate(out NSError error);
}