Tuesday, September 25, 2012

Failed to complete operation Visual Studio 2008 2010

Sometimes, when compiling and running a source code in Visual Studio, you get the error "Failed to complete operation" and the project will not run although you have build successfully. You'll know that the build is successful if you try to run the application by going to the BIN folder and running the compiled binary manually. I've been trying to find answers to this error but I've not bumped into a solution until now. Before I tell you the solution I've found, let me tell you how I usually fix it. To make the application run again, I try to do several things after and before I open Visual Studio.

1. If Visual Studio is already open and I'm feeling lazy, I try to do a Build > Clean Solution , then a Build > Rebuild All. This will usually not work. I follow this up by going to the bin folder and deleting the remaining files in the Bin folder. This will leave 1 file which is vshost.exe. If it still does not work, I run the vshost.exe manually.

2. If the above doesn't work (which usually doesn't). I have to close Visual Studio and delete the BIN and OBJ folders manually. This method worked 100% of the time.

This just sucks. There's also no log file that tells you what's wrong as far as I know.

AND NOW... let me tell you how to fix this permanently.

I was using a c# WPF for .net 4.0 project for this and I don't know if this is the same with other projects. I haven't had the need to investigate yet. Please comment if it works on other types of projects. Here are the Steps:

1. Go to the Property Pages of the project your working on. This can be done by selecting the project in the Project Explorer then going to View > Property pages or via the keyboard shortcut SHIFT+F4.

2. In the property pages, go to the Debug page and under Enable Debuggers, [UNCHECK] Enable the Visual Studio hosting process. Note: You'll have to do this for the target configuration (e.g. Release, Debug) or you can just select under the Configuration: pull down menu "All Configurations" to apply it across all future builds.

That's it. Please Comment if this worked for you.

Tags:
Program not running after Run or Compile F5
Failed to complete operation

Thursday, August 2, 2012

Errors encountered on Rx (Reactive Extensions) HOL (Hands on Lab)

Problems doing HOL
Error doing HOL
Hands on labs errors

Reactive extensions (Rx) in .Net intends to solve the nightmares of asynchronous programming. The concept is really new to me and I tried doing the Rx Team's HOL (Hands on Lab) for Rx in C#. Since the HOL was last updated a number of changes have been made. These are the troubles I encountered while doing the Rx HOL.

 1.
source.Run( x => Console.WriteLine("OnNext: {0}", x), ex => Console.WriteLine("OnError: {0}", ex.Message), () => Console.WriteLine("OnCompleted") );
Solution: Use ForEach or Do.
See: http://social.msdn.microsoft.com/Forums/en-US/rx/thread/398452c2-c97d-4d96-b784-2a2e8a026d12



2. Cannot create a breakpoint inside lambda expression, lambda statement:

Solution: The answer is actually on the HOL pdf. But if you are stupid like me and thought you could set a breakpoint the usual way then how wrong you are. It took me a few minutes to find out that a breakpoint cannot be set inside a lambda expression by clicking on the grey bar or by Pressing F9. The way to do it is to click inside a statement then press F9.

e.g. Click on the OnNext word inside WriteLine() then press F9.


3.  
var moves = Observable.FromEvent(frm, "MouseMove");
Solution: Use FromEventPattern instead. 
var moves = Observable.FromEventPattern(frm, "MouseMove");

4.
using (new CompositeDisposable(movesSubscription, inputSubscription))
Solution: Fully qualify it.
 using (new System.Reactive.Disposables.CompositeDisposable(movesSubscription, inputSubscription))

5.
var moves = Observable.FromEvent(frm, "MouseMove"); 
var input = Observable.FromEvent(txt, "TextChanged");
Solution: Same as 3. Use  FromEventPattern
var moves = Observable.FromEventPattern(frm, "MouseMove"); 
var input = Observable.FromEventPattern(txt, "TextChanged");

6. ObserveOn(lbl) error HOL.
using (input.ObserveOn(lbl).Subscribe(inp => lbl.Text = inp))
Solution: Make sure you add System.Reactive.Windows.Forms as a reference

7. DictServiceSoapClient not found
var svc = new DictServiceSoapClient("DictServiceSoap");
Solution: Add a add a "using"  to the header with the namespace of the service reference you created.
e.g.  using RxLab.DictionarySuggestService;


Tags: C# RX, c# reactive extensions

Friday, July 13, 2012

Error: The version of the .NET Framework launch condition '.NET Framework 4' does not match the selected .NET Framework bootstrapper package

After trying out the solutions suggested on THIS PAGE and still didn't get the issue resolved, I found the solution, the fix, the answer!

The primary fix suggested by the people there is:

1.  Main Project Properties - Compile Tab - Advanced Compile Options -  Target Framework
 Pics for step 1:





2.  Deployment Project Properties - Prerequisites - Correct Framework checked.
Pics for step 2:




3.  Right-click on Deployment project - View - Launch Conditions.  In the Launch Condition tab, right-click the .Net Framework Launch condition, then show Properties Window.  In the Properties Window, make sure that the Version property is the correct Framework.
Pics for Step 3:
 
 


How I SOLVED it:

If after doing the above steps you still have the error try this:
1. Right Click the Installer Project, on View > Launch Conditions.
2. Click on .Net Framework
3. On the Properties page, Change the Version to Any.

4. Rebuild the solution.
5. Change the Version back to your target framework. In my case it's .NET Framework 4.



That's it. The warning message disappeared after I did this. I don't know why it happens but I fixed it this way.


C#, Visual Studio 2010,