Skip to main content

Posts

Showing posts from March, 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"); Process.Start(shortcutName);

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.

Using Thread: // 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(); Using Task and Thread: // Creating Task Pool, Each task will work asyn and as an indivisual thread component Task[] tasks = new Task[3]; // Control drug data disc UI load optimize tasks[0] = Task.Run(() => { //This will handle the ui thread :The calling thread must be STA, because many U

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>