Search code examples
c#wpfvisual-studio

Remote development finds that the value in the combox is empty


Our company mainly develops on remote computers. This project uses vs2019 to compile this code normally, and the combobox drop-down box has data. But if the compiled exe is copied to another computer to run, there will be no data in the combobox drop-down box. I checked this project in vs2019. Combobox1 does not have the ItemsSource attribute, but because the code is very old and not written by me, and I can get the drop-down box data of combobox1 when compiling in vs2019, so it is very strange. This doesn't have the attribute itemssource which actually works. But copy the compiled exe to another computer to run, the combobox drop-down box will not display data, and the itemssource will be invalid at this time. Of course, please ask the boss to say that this code was written in vs2013 before.

Due to company regulations, I can only provide these codes:

  DataSet ds=new System.Data.DataSet();
  ds.Merge(GlobalVariable.DBoper.GetDownLoadProcessRecords(20));
  combobox1.ItemsSource=ds.Tables["GetName"].AsDataView();

What is the problem? Any suggestion is worth considering.


Solution

  • When uploading the exe file to the remote computer, you need to modify the specified data source, otherwise, if the program cannot access the data source, the combobox drop-down box will appear blank. Also, make sure your local operating environment and even the database are consistent with the remote computer.

    Of course, there is another situation that the exe file cannot be directly copied to other operating environments. That just copied the exe and didn't copy other dependent files. So it's hard for your wpf program to run normally.

    If you confirm that your remote operating environment is the same as the local operating environment, and it is inconvenient to upload the dll to the remote computer together, you can try to use ILMerge to merge the dll file into the exe, so that you only need to upload the exe file to the remote computer.

    But ILMerge only supports Winforms. Use ILMerge in wpf, please refer to Merging dlls into a single .exe with wpf