My app installs on a native Win10 PC and is able to run with on issues. However, when a user installs the app on a Win7/Win10 VM, the they encounter a crash with the following stack trace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 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.
at Services.CertService.RefreshCerts() in C:\Users\Services\CertService.cs:line 49
at Services.CertService..ctor(IAppSettings appSettings) in C:\Users\Services\CertService.cs:line 43
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at GalaSoft.MvvmLight.Ioc.SimpleIoc.MakeInstance[TClass]() in c:\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:line 727
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at GalaSoft.MvvmLight.Ioc.SimpleIoc.DoGetService(Type serviceType, String key, Boolean cache) in c:\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:line 567
at GalaSoft.MvvmLight.Ioc.SimpleIoc.GetInstance[TService]() in c:\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:line 912
at WebServices.Login..ctor(Boolean signIn) in C:\Users\WebServices\Login.cs:line 69
and the class constructor for Login is:
69: protected Login(bool signIn = true)
70: {
71: var service = ServiceLocator.Current.GetInstance<ICertService>();
72: if (service != null)
73: {
74: if (signIn)
75: {
76: /* do something */
77: }
78: else
79: {
80: /* do something else */
81: }
82: }
83: }
Inside the CertService class we have the following:
34: public class CertService : ICertService
35: {
36: private readonly IAppSettings appSettings;
37: private Dictionary<string, string> pCerts;
38: private List<string> hList;
40: public CertService(IAppSettings appSettings)
41: {
42: this.appSettings = appSettings;
43: this.RefreshCerts();
44: }
46: public void RefreshCerts()
47: {
48: this.pCerts = new Dictionary<string, string>();
49: this.hList = new List<string>();
...
}
I think I am missing a dependency that I need to install on my VM. I can't think that this would be a code issue since it doesn't happen on a native Windows machine.