Concatenating Strings to Build File Paths

Here is an easy one – more so for my reference but it may help others. Let’s suppose you are concatenating strings to build a file path. Perhaps you have an application that automatically generates invoices in docx format and you need to save these files in a specific folder. Each file needs to be named based on the full name of a customer. There is no right or wrong way to do it, but we might as well utilize .NET methods if they make this process simpler.

Example 1: Using string.Format

string filePath = string.Format(@”C:\myfolder\mysubfolder\{0}.txt”, c.FullName);

Example 2: Using Path.Combine

string filePath = Path.Combine(@”C:\myfolder\mysubfolder\”, c.FullName);

Error Importing a Solution in CRM 2011

I found an interesting issue the other day while attempting to import a managed solution into our test environment. I had previously completed the solution import without issues but this time I received the following error:

This workflow cannot be created, updated or published because it was created outside the CRM web application. Your organization does not allow this type of workflow.

I’m not really sure why we got this error since the workflows were in fact created from the CRM application. You would normally receive this error if you created custom XAML workflows inside Visual Studio. To fix the problem, perform an iisreset on the CRM server and try the solution import again.

Configuration Settings in Windows Azure

This week I have had some fun with Windows Azure web and worker roles where I built a polling service to pull data from an external system into Microsoft Dynamics CRM 2011. One of the important factors of the polling service was to include configurable settings such as the time between synchronizations (in minutes) and the connection string to a SQL Azure database. In this post, I will show you how to add and read these configuration settings.

In Visual Studio, expand your Windows Azure project and then click on roles. Right-click on the role you wish to add a configuration setting to and then click on Properties.


Click on the Settings tab and then click on Add Setting. Give the setting a meaningful name and a value. Rebuild the project to save the setting.

Here is an example of how to read the settings inside your code:

string setting = RoleEnvironment.GetConfigurationSettingValue(“sync.time”);

When you upload the package into Windows Azure, you will be able to manage the configuration settings from within Configure area inside the Windows Azure portal. One important thing to note is that the setting values you specify inside the Visual Studio project will act as the default values so if you update any settings inside the portal and then re-upload the package, your settings will get overwritten.


It’s been a long time coming but finally I’m writing my first post. I’ll quickly introduce myself – I’m Roshan Mehta, a .NET developer at Magnetism specializing in custom software on the Microsoft Dynamics CRM 2011 platform. This blog will primarily be used to track my learning as I take on the challenge of exploring new technologies. I will also post stuff about Microsoft Dynamics CRM and anything else I’m interested in.

I hope that my posts will help other developers but feel free to leave me comments if you can suggest better ways to do things.