Showing posts from March, 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 })); }

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"); Process.Start(shortcutName);

Devexpress report Export in to file

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

XtraReport report = new Test(); report.CreateDocument(); report.ExportToText("D:\\test1.doc");

C# kill specific process

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

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); obj.Show(); // Start the Dispatcher Processing System.Windows.Threading.Dispatcher.Run(); })); // Set the apartment state newWindowThread.SetApartmentState(ApartmentState.STA); // Make the thread a background thread newWindowThread.IsBackground = true; // Start the thread newWindowThread.Start();

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" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> </configuration>