Tenho uma classe UsuarioApp, que tem um endereço, do tipo Endereço(outra classe minha), que dentro de endereço tem um bairro, e dentro de bairro uma cidade. UsuarioAPP > Endereço > Bairro> Cidade; Estou tentando inserir uma cidade e estou recebendo o erro:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
05-29 23:38:58.191 E/mono (10663):
05-29 23:38:58.191 E/mono (10663): Unhandled Exception:
05-29 23:38:58.191 E/mono (10663): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
05-29 23:38:58.191 E/mono (10663): at SalveMariaR.ViewModel.CadastroViewModel.set_CidadeSelecionada (SalveMariaR.Model.Cidade value) [0x00001] in C:\Workspace\SalveMariaR\SalveMariaR\SalveMariaR\ViewModel\CadastroViewModel.cs:215
05-29 23:38:58.191 E/mono (10663): at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
05-29 23:38:58.191 E/mono (10663): at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
05-29 23:38:58.191 E/mono (10663): --- End of inner exception stack trace ---
05-29 23:38:58.191 E/mono (10663): at (wrapper dynamic-method) System.Object.68(intptr,intptr,intptr,int)
05-29 23:38:58.191 E/mono (10663): at (wrapper native-to-managed) System.Object.68(intptr,intptr,intptr,int)
05-29 23:38:58.191 E/mono-rt (10663): [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
05-29 23:38:58.191 E/mono-rt (10663): at SalveMariaR.ViewModel.CadastroViewModel.set_CidadeSelecionada (SalveMariaR.Model.Cidade value) [0x00001] in C:\Workspace\SalveMariaR\SalveMariaR\SalveMariaR\ViewModel\CadastroViewModel.cs:215
05-29 23:38:58.191 E/mono-rt (10663): at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
05-29 23:38:58.191 E/mono-rt (10663): at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
05-29 23:38:58.191 E/mono-rt (10663): --- End of inner exception stack trace ---
05-29 23:38:58.191 E/mono-rt (10663): at (wrapper dynamic-method) System.Object.68(intptr,intptr,intptr,int)
05-29 23:38:58.191 E/mono-rt (10663): at (wrapper native-to-managed) System.Object.68(intptr,intptr,intptr,int)
05-29 23:38:58.192 D/ (10663): HostConnection::get() New Host Connection established 0x85ff5b00, tid 10663
Minha classe UsuarioApp:
public class UsuarioApp
{
public int id { get; set; }
public string nome { get; set; }
public string nomeMae { get; set; }
public string nomePai { get; set; }
public DateTime dataNascimento { get; set; }
public string cpf { get; set; }
public string rg { get; set; }
public string idade { get; set; }
public Endereco endereco { get; set; }
}
minha classe endereço:
public class Endereco
{
public long id { get; set; }
public string logradouro { get; set; }
public string numero { get; set; }
public string complemento { get; set; }
public string cep { get; set; }
public Bairro bairro { get; set; }
public string estado { get; set; }
public string latitude { get; set; }
public string longitude { get; set; }
}
minha classe Bairro:
public class Bairro
{
public Cidade cidade { get; set; }
public string nome { get; set; }
public long id { get; set; }
}
minha classe Cidade:
public class Cidade
{
public long id { get; set; }
public string nome { get; set; }
}