Everyone hates to see build errors. Especially when they are exploring a new piece of technology, which they have no background knowledge on. I hit “The type or namespace name ‘ServiceBus’ does not exist in the namespace ‘Microsoft'” build error today and this blog is going to go over how to resolve this issue.
I ran into the issue “The type or namespace name ‘ServiceBus’ does not exist in the namespace ‘Microsoft'” when I was trying to follow a tutorial called “Getting Started with AppFabric Service Bus” (http://msdn.microsoft.com/en-us/library/windowsazure/ee706738.aspx).
Initially I thought that my SDK wasn’t up to date or something went wrong during the installation of the SDK. So I tried the usual uninstalling and re-installing of Azure AppFabric SDK and then the entire Windows Azure SDK. That didn’t solve the problem.
Getting more frustrated with my previous attempts, I then decided to repair my Visual Studio 2010 installation because I thought there is something seriously wrong happening between the Windows Azure App Fabric SDK and my Visual Studio installation. Again this did not solve the problem.
Some point between re-installing the SDK and repairing my Visual Studio installation, I also tried copying the Microsoft.ServiceBus.dll from Windows Azure AppFabric SDK directory to my project directory and ensured that the permissions of the assembly were sufficient for Visual Studio to access it. Despite doing all of this, the issue just wouldn’t resolve.
After trying all of the above and still receiving issues, I decided to walk away from my machine and hope that things would magically work the next time I tried to repeat the tutorial. It didn’t however I FINALLY figured out the culprit behind this issue. Ready for it? It was the default properties set on a new project. (You can view this by right clicking on your project -> Properties.)
By default, the Target Framework that your project is built under is “.NET Framework 4 Client Profile”. You want to change the Target Framework to “.NET Framework 4”. Once you do this, then all the build error “The type or namespace name ‘ServiceBus’ does not exist in the namespace ‘Microsoft'” will disappear.