Within my view model constructor, I create a background worker using BackgroundWorker pattern and then I perform a query against a database (Informix) through a webservice in the background worker just created:
public wMainViewModel(IView view)
{
BackgroundWorker BWorkerInit = new BackgroundWorker();
BWorkerInit.WorkerReportsProgress = false;
BWorkerInit.WorkerSupportsCancellation = true;
BWorkerInit.DoWork += new DoWorkEventHandler(BWorkerInit_DoWork);
BWorkerInit.ProgressChanged += new ProgressChangedEventHandler(BWorkerInit_ProcessChanged);
BWorkerInit.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BWorkerInit_RunWorkerCompleted);
BWorkerInit.RunWorkerAsync();
}
private void BWorkerInicialitzar_DoWork(object sender, DoWorkEventArgs e)
{
List<Dept> ListDepts;
int res = MyDataHelper.GetDepts(out ListDepts);
// Continue doing other stuff
}
My MyDataHelper is as follows:
public static class MyDataHelper
{
#if DEBUG
private static MyWebservice_Local_Testing.WSCore ws = new MyWebservice_Local_Testing.WSCore(); // <----- HERE IT CRASHES
#else
private static MyWebservice.WSCore ws = new MyWebservice.WSCore();
#endif
public static int GetDepts(out List<Dept> oListDepts)
{
System.Data.DataSet ds = ws.GetDepts();
// Continue doing other stuff
}
}
When debugging application, in the output window, I can see that an exception is thrown despite application is being executed correctly and performing the database query correctly.
Exception thrown:
an unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
This exception is thrown in the constructor within Reference.cs file auto-generated automatically by visual studio ide:
public WSCore() {
this.Url = global::My.Apps.WPF.CompanyManagement.Properties.Settings.Default.CompanyManagement_MyWebservice_Local_Testing_WSCore;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
InnerException says:
could not load file or assembly 'CompanyManagement.XmlSerializers, Version=1.6.0.3, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"CompanyManagement.XmlSerializers, Version=1.6.0.3, Culture=neutral, PublicKeyToken=null
StackTrace:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)