Friday, February 01, 2008

"Upgrading" custom code from 3.0 to 4.0

After the number of upgrades that myself any my team have performed we've found that there is a bit of work that needs to be done to make your 3.0 code work in 4.0. This code that I'm talking about is not scripting code, but callout, workflow assemblies, and custom webpages. Here are some tips and tricks that we've found you should do to make everything work smoothly. A lot of times a majority of your custom code will work but there will be a few that don't work. I've had callouts that were in the same DLL file and 80% of them worked and I had to do a little tweaking to get the other 20% up and running smoothly.

1. Move all code to ASP .NET 2.0
This means that you should convert your code from Visual Studio 2003 to Visual Studio 2005. CRM 4.0 is built on .NET 2.0 and everything just runs more smoothly when its all on the same framework. This shouldn't be a big deal for callouts but for some webpages this could be an issue if you need to replace some .NET 1.1 controls with .NET 2.0 controls. Such as DataGrids, which become GridViews in .NET 2.0.

2. Remove and re-add the CRM web reference
The web references go to ASPX pages (both in the 3.0 and 4.0 URL's). You can use the same URL (http://<CRMServerName>/MSCRMServices/2007/CRMService.asmx) and Visual Studio will redirect to the CRMServiceWSDL.aspx page automatically for you. Either way, I recommend rebuilding it so that it runs smoother. I have done this trick on probably all of the upgrades I've done to get at least one callout to work.

3. There maybe a few code changes that you will have to make manually.
As one of my readers, Maria, pointed out, CRMFloat.Value is now a double instead of a float. Unfortunately I don't know all of the in's and out's yet but just know that you may need to do some code combing if worst comes to worst. Obviously leave this option as a last resort as it is the most tedious and time consuming.

4. Restart the Async Service whenever you do an IISReset.
Apparently you shouldn't have to, but I've spoken with a couple of MSSupport reps and they will still restart the Async Service after an IISReset. They aren't linked but they do feed off of each other and I always kick myself or at least slap myself really hard whenever the solution to my problems in coding is restarting a service. It doesn't hurt to do it, and it adds what, 3 extra seconds if you've already gotten approval to bring one or the other down? I say spend the extra 3 seconds just to be sure.

That's it. Not too many, but then again if there were many more I'd be really concerned.

Hopefully all of your upgrades are running smoothly and everyone is enjoying the new version of MSCRM.

David Fronk
Dynamic Methods Inc.

14 comments:

Anonymous said...

I've gone through all these steps and still can't get my 3.0 callouts to do anything (register or even seem like they exist) in 4.0. Please detail the part where you've gone through all these steps and then you register the callouts. The registration tool in 4.0 won't recognize any 3.0 callouts in my dll.

Dynamic Methods said...

You actually don't register your 3.0 callouts. You deploy them just like you deployed them back in 3.0. Through the callout.config file and placing your DLL in the bin\assembly folder.

Make sure you update your WSDL and also, you might want to check your event log to see if you have any errors showing there. One other thing I've run into is that the ISVCustomizations tag in the web.config file gets set back to "none" and you will need to change that to be "all" or "web" or "outlook" depending on your deployment. Your problem could be something as simple as that. Because if that is set to "none" then no callouts will fire, ever.

David Fronk
Dynamic Methods Inc.

Unknown said...

Hi David,

Did you need to install a version of the Microsoft.Crm.Platform.Callout.Base.dll into the GAC? CRM 4 doesn't seem to install it, and in fact removes version 3's.

If you did install it, which version did you install?

We're having this crazy problem here that PreCreate callouts from v3 that would modify the entityXML now have their modifications ignored. This is actually a custom field on the account entity we are trying to get defaulted at creation time :(

Cheers,

Chris

Dynamic Methods said...

Chriskl,

I actually have seen a couple of deployments where I had to register the microsoft.crm.platform.callout.case.dll to the GAC (C:\WINDOWS\assembly) folder in order to get callouts to work. I haven't had to do it on all installations/upgrades so I'm not sure what causes the dll to be removed from the GAC during upgrade. I just installed the dll that is provided in the CRM 4.0 media at CD Drive:\bin\assembly.

Once you do that it should make your old callouts work. You may need to recompile, and possibly update your WSDL in your code but after I add the callout dll to the GAC my callouts would start working.

Hope this helps you out.

David Fronk
Dynamic Methods Inc.

Anonymous said...

Nice blog David,

I am getting an error when trying to aquire the new WDSL to re-build my callouts.

Any ideas?
Thanks
Duane

Server Error in '/MSCRMServices' Application.
--------------------------------------------------------------------------------

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'Microsoft.Crm.WebServices' or one of its dependencies. The system cannot find the file specified.

Source Error:


Line 55: lt! configuring the reflector + format extension for custom WSDL generation gt
Line 56: lt soapExtensionReflectorTypes gt
Line 57: lt add type="Microsoft.Crm.Sdk.CrmServiceSoapExtensionReflector, Microsoft.Crm.WebServices" /gt
Line 58: lt/soapExtensionReflectorTypes gt
Line 59: lt conformanceWarnings gt


Source File: C:\Program Files\Microsoft CRM\CRMWeb\web.config Line: 57


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

Dynamic Methods said...

Duane,

Callouts run on .NET 1.1, your error is showing that you are using .NET 2.0, so that's probably your first problem. Secondly, DO NOT link your callouts up to the new WSDL. Use the http://servername/mscrmservices/2006/crmservicewsdl.aspx reference in your code for all callouts. They left that WSDL there so that your callouts would still be compatible. The authentication is completely different between the 3.0 WSDL and the 4.0 WSDL.

Fix those two things and I think you'll be well on your way to getting your callouts working again.

David Fronk
Dynamic Methods Inc.

Anonymous said...

the web.config file does not have that section for ISVCustomization

Dynamic Methods said...

You are correct, I misspoke. I'm so used to the ISVCustomization tag being in the web.config from the previous versions that I just wrote that out. The functionality for changing the ISVCustomization options (Web, Outlook, All) has moved in CRM 4.0 to the System Settings area on the Customization tab.

Thanks for catching my error.

David Fronk
Dynamic Methods Inc.

Anonymous said...

my Callout still not working after upgrading to CRM 4.0 altough I have put Microsoft.CRM.Callout.Base to GAC and Callout.dll to assembly\bin folder.

Is there any step that I missed here ?

Thanks

Dynamic Methods said...

Does your GAC have the following dll's?:

Microsoft.Crm.Outlook.Sdk
Microsoft.Crm.Sdk
Microsoft.Crm.SdkTypeProxy
Microsoft.Crm.WebServices

Is there a specific error you are getting? Is it common among all callouts? You mentioned that you placed the Callout.dll in the assembly folder, did you put your callout.config.xml file there as well?

Hopefully that gives you a few additional places to check.

David Fronk
Dynamic Methods Inc.

Anonymous said...

I am one step before that. The installation I am working on has numerous customizations so I want to get the WSDL from the Server rather than the SKDTyped one. I reference both the Web Service (from the address http://servername[:port]/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName) and the discovery Service (http://servername[:port]/mscrmservices/2007/ad/crmdiscoveryservice.asmx)

The problem is that the resulting WSDL is missing classes that the SDKTypeProxy contains most importantly the CRMService class.

If I use both as you suggest then I get ambigous calls and say I pass the full designated names to avoid that... I always get into a pickle when I need to pass a Server WSDL generated class into the Microsoft SDKtypeProxy service...

I am probably doing something that you are going to consider ridiculous and trivial... but can you help please

Dynamic Methods said...

From the looks of it you are using the wrong WSDL. If you are trying to get callouts to work you cannot use the 4.0 WSDL (the one with 2007 in the URL), you need to use the old WSDL. Here's the URL you should try:

http://servername[:port]/mscrmservices/2006/crmservice.asmx

That is the only one you need. Don't use the discovery service, or the main 4.0 WSDL. The callout model hasn't changed, and the new WSDL's have different authentication as well as other additions that callouts don't know how to handle. Change that and I bet that will get everything working again.

David Fronk
Dynamic Methods Inc.

Anonymous said...

When typing the web service (http://:[Port#]/mscrmservices/2006/crmservice.asmx)
in IE, it gets redirected to the WSDL? I'm not getting the page listing the methods as I did with CRM 3.0. I'm not sure if this is normal behavior of if I have an issue. Can you please help?
Thanks!

Dynamic Methods said...

This is some new "feature" that has been added in CRM4. I also cannot get to the definition page as the ASMX page automatically redirects to the WSDL page.

My suggestion would be to just use the SDK and use that as it has all of the definitions and calls you will need.

David Fronk
Dynamic Methods Inc.

Post a Comment