Wednesday, March 16, 2016

The calling thread cannot access this object because a different thread owns it.

On your do work

  private void worker_DoWork(object sender, DoWorkEventArgs e)  
       this.Dispatcher.Invoke((Action) (() =>  
         // Your code  

Wednesday, March 9, 2016

C# - Process.Start a ClickOnce application

  string publisher_name = "ABCPublisher";  
       string product_name = "FaxManFMFFileCreator";  
       var shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\",publisher_name, "\\", product_name, ".appref-ms");  

Devexpress report Export in to file

Test is the devexpress report and you can export in different format.

  XtraReport report = new Test();  

C# kill specific process

  //Threading for speacific printer otherwise it will open default Faxman printer  
       Task.Factory.StartNew(() =>  
         // Killing Process of default printer  
         Process[] processes = Process.GetProcessesByName("FaxManFMFFileCreator");  
         foreach (var process in processes)  

Tuesday, March 8, 2016

The calling thread must be STA, because many UI components require this.

  // Create a thread  
       Thread newWindowThread = new Thread(new ThreadStart(() =>  
         // You can use your code  
         // Create and show the Window  
         FaxImageLoad obj = new FaxImageLoad(destination);  
         // Start the Dispatcher Processing  
       // Set the apartment state  
       // Make the thread a background thread  
       newWindowThread.IsBackground = true;  
       // Start the thread  

Monday, March 7, 2016

Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":null

Create app.config and modify it

 <?xml version="1.0" encoding="utf-8" ?>  
  <startup useLegacyV2RuntimeActivationPolicy="true">  
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />  

C# print file on LAN Printer

If you want to print any file on network printer then you can try with this code block // Change Default Printer System.Ma...