Solution file (.sln) lost CRM Developer Toolkit Instance

I’ve encountered this issue several times (especially when we are check in to TFS), that the solution file is not merged properly, and for some reason the developer toolkit bind is removed.

 
To fix this, edit .sln file using notepad/any text editor, then add:
 
GlobalSection(CRMSolutionProperties) = preSolution
  SolutionIsBoundToCRM = True
EndGlobalSection​
 
In Global, after:
 
GlobalSection(TeamFoundationVersionControl) = preSolution

 

CRM 4.0 Deployment Problem – web.config cannot be loaded properly

Today I developed an application to be deployed in ISV. However as per request I couldn’t use the default organization,
so I need to change the url from:
http://(server-name)/ISV/(app-name)
to:
http://(server-name)/(organization-name)/ISV/(app-name)

The problem is my current web.config couldn’t be loaded properly. I got empty configuration even I use existing configuration from other project that use the same CRM.
After a chat with my work mate, he come accoss to Janne Mattila’s blog and I found the solution.

That’s a relief, yet not the end of the problem. I have a project that contains all CRM functions there. The solution above only applicable if I use those functions in one project, unfortunately I use it accross several projects.
So after some time and a chat with my work mate again we come into a solution:

1. I create a function in the config class that I use for the projects

public static void LoadCustomConfigFile()
{
// open the configuration on this specific path
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("/ISV/");

// get all configuration that starts with "Crm" keyword - use "Crm" keyword for Crm related settings
var crmConfigurationKeys = configuration.AppSettings.Settings.AllKeys.Where(k => k.StartsWith("Crm")).ToList();

foreach (var crmKey in crmConfigurationKeys)
{
ConfigurationManager.AppSettings.Set(crmKey, configuration.AppSettings.Settings[crmKey].Value);
}
}

2. On page load event in the ISV application

protected void Page_Load(object sender, EventArgs e)
{
// Load custom config
Config.LoadCustomConfigFile();

// do the rest of page load event
}