Tag Archives: Visual Studio 2010

Debugging CRM web resources without ever deploying them

UPDATE: The steps explained below don’t work with CRM 2013.  However, Scott has a blog post which shows you how to get it working again:

http://develop1.net/public/post/Fiddler2-The-tool-that-gives-you-Superpowers-Part-2.aspx

One of my last posts was sharing how I use Visual Studio to debug CRM web resources:

http://blogs.msdn.com/b/devkeydet/archive/2013/06/19/eureka-f5-debugging-of-crm-javascript-web-resources.aspx

This approach was one of those discoveries that makes us developer types get a little excited because it allows us to do something we do repeatedly in a much more efficient fashion.  I just came across another one of those EUREKA moments thanks to Scott Durow (@scottdurow) and some his promising new http://www.sparklexrm.com project. 

BTW, Scott’s the man behind Ribbon Workbench for Dynamics CRM.  It’s the best Ribbon editor out there in my opinion.  I digress…

I was reading through http://www.sparklexrm.com/s/Tutorials/SetUpNewProject.html and discovered a little gift from Scott at the end of the walkthrough.  Steps 9-14 explain how to use www.fiddler2.com to let you debug changes to web resources without ever having to deploy them to Dynamics CRM.  How?  Steps 9-14 explain it.

Combine this with my post on F5 debugging from Visual Studio and you nearly have web resource developer productivity nirvana.  I just tried combining the two approaches.  It works beautifully!  I was able to make changes to JavaScript, hit F5, debug right in Visual Studio, and repeat over and over again.  I did this all without ever having to deploy the JavaScript file to the server.  Because of it, I was able to iterate on my changes in a fraction of the time CRM developer typically spend.  Try it yourself!

@devkeydet

WEBCAST FOLLOW UP: Unit Testing Dynamics CRM Plugin and JavaScript code

Thanks to everyone who attended my presentation on Unit Testing Dynamics CRM Plugin and JavaScript code hosted by http://www.xrmvirtual.com/.  I’ll update this post when the recording is available.  However, the webcast was basically a shortened walkthrough of these two posts:

http://blogs.msdn.com/b/devkeydet/archive/2012/10/31/how-i-develop-and-unit-test-crm-2011-plugins.aspx

http://blogs.msdn.com/b/devkeydet/archive/2012/11/27/unit-testing-crm-2011-javascript-web-resources.aspx

…with some additional “what is and why unit testing” commentary.

Here’s the presentation:

@devkeydet

CRM, Accessibility, and 508

I’ve spent many a time having accessibility and 508 compliance discussions with customers and partners over the years working at Microsoft and focusing on various web based technologies.  In fact, it’s hard to believe I recorded this video over seven years ago:

https://channel9.msdn.com/Blogs/keydet/Creating-an-Accessible-Web-Page

As it relates to Dynamics CRM 2011, whether your overall implementation is accessible is a combination of:

  1. Whether the HTML the CRM product produces is accessible
  2. Whether your web resources are accessible
  3. Whether any custom ASP.NET, etc. pages integrated into the CRM UI (say through iFrames) are accessible

For #1, the CRM product team produces a document called a Voluntary Product Accessibility Template (VPAT).  Ben does a good job explaining the relationship to 508 compliance and VPATs here so I won’t go into it.  As Ben mentions, all of Microsoft’s VPATs are available at:

http://www.microsoft.com/government/en-us/products/section508/Pages/default.aspx

The most recent VPAT for Dynamics CRM 2011 (as of writing this) is: Microsoft Dynamics CRM December 2012 Service Update VPAT.  For #2, the CRM 2011 SDK has a section called Create Accessible Web Resources to help you.  This section is chock full of resources and links to external resources on accessibility.  What surprised me is that it doesn’t talk about Visual Studio’s built in accessibility checker which is covered in Visual Studio’s Accessibility in Visual Studio and ASP.NET documentation.  For #3, you need to similarly understand how to make sure those pages are accessible.  Visual Studio’s ASP.NET Controls and Accessibility should prove helpful.  In fact, the 7+ year old video I recorded that I link to earlier shows both the accessibility checker and general ASP.NET accessibility techniques in action.  Hopefully this post is helpful to those of you who are going to be in the business of ensuring your CRM implementation is accessible.  Here are a few other resources you will want to review which are not linked from the other resources in this post as far as I can tell:

http://webaim.org/

http://www.section508.gov/

Now that the latest CRM Online update is complete and UR12 is out, Dynamics CRM 2011 is now cross browser capable.  Therefore, you can now use the popular WAVE Toolbar Firefox addon to check accessibility of your customizations.  Yea, I know, a Microsoft guy recommending Firefox.  I don’t know of a better free tool that allows you to check accessibility of web pages without uploading html or point the tools servers at your web site.  The latter kind of validator won’t work for CRM deployments because of authentication.  Plus, you should be testing all your customizations in Firefox and Chrome anyway.

@devkeydet

Visual Studio, ALM & Dynamics CRM

UPDATE (17MAY2013): There’s now a whitepaper on the topic as well: ALM for Microsoft Dynamics CRM 2011: CRM Solution Lifecycle Management

NOTE: I’ve included related links to both Visual Studio 2010 & 2012 content.  Even thought the Developer Toolkit for Microsoft Dynamics CRM now supports Visual Studio 2012, I recognized not everyone has upgraded.  I do my best to differentiate VS2010 & VS2012 where necessary.  You can always switch to the right version of the documentation if you click the wrong link:

image

I’ve had a recurring discussion lately about using Visual Studio’s Application Lifecycle Management (ALM) tools:

http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.100).aspx (Visual Studio 2010)

http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.110).aspx (Visual Studio 2012)

…including Team Foundation Server (TFS), when developing Dynamics CRM 2011 solutions.  CRM Development is a little different than traditional software development because you write much less code than building something from scratch (in some cases no code).  However, I am a firm believer that CRM projects should be RUN just like a custom dev project.  Especially enterprise projects.  Enter Visual Studio ALM…

Many think of Visual Studio and Team Foundation Server as just for developers, but if you read through the links above, you will learn there’s much more than what you might think.  However, leveraging all of these capabilities in the context of a Dynamics CRM project isn’t really spelled out anywhere.  This post is an attempt to be a contextualized table of contents of public information to help people understand how the two worlds collide.  The 2010 version of the ALM starter page breaks Visual Studio ALM down to:

  • Plan and track your project. Enact processes and monitor their quality to help your team turn customer requirements into working software.

  • Design functionality, either on top of existing assets or from scratch, by using architectural diagrams to communicate critical information about your team’s software.

  • Write, unit test, debug, analyze, and profile your application by using tools that are integrated with the rest of the application lifecycle so that your team can understand how your progress contributes to the project. Use version control to manage your source code and other files.

  • Build your application by using an integrated build system so that your team can ensure that quality gates have been met and verify that requirements have been fulfilled in each build.

  • Test your application by running manual or automated tests, including performance and stress tests. Manage testing systematically so that your team knows the software quality on any given day.

  • Deploy into virtual environments to enable more sophisticated development and testing.

I’m going to use this as the structure of my mapping to CRM.  There’s nothing really specific to Plan and track with CRM.  However, I find it surprising how few people are using the Visual Studio planning and tracking tools (work item / bug tracking, reports, etc.) on CRM projects.  Definitely review the material to learn about how TFS can help you run your projects.  The next area where Visual Studio can really help is Write, unit test, debug, analyze, and profile.  With CRM, you “develop” with two primary tools: The CRM Web UI and Visual Studio (usually with the Developer Toolkit for Microsoft Dynamics CRM):

CRM UI to edit Visual Studio / Other to edit
Entities, Attributes, Relationships
Forms & Views
Charts, Dashboards, Basic Reports
Workflows & Dialogs
Templates
Security Roles & Field Security
HTML, JavaScript, CSS
XML / XSL
Images
Sitemap & Ribbon
Plugin & Workflow code
Companion ASP.NET code

 

In may cases, you also use community tools to do things like site map and ribbon customizations.  However, in the end, those tools ultimately modify the CRM system (usually by modifying XML files).  So the writing code part should be pretty self explanatory through the CRM SDK (online / download) and developer toolkit.  The first place where you need to sprinkle in additional CRM context/nuance is unit testing.  My posts here should help you:

How I develop and unit test CRM 2011 plugins (make sure to use Fakes instead of Moles if you are using Visual Studio 2012)

Unit testing CRM 2011 JavaScript web resources

Debugging is another place where people get a little tripped up.  There are multiple approaches to debugging both plugins and web resources.  Debug a Plug-In explains how to attach Visual Studio to the right process to debug plug-in and workflow code.  Of course this requires you to attach to the CRM Server.  In cases where you can’t, you can profile code execution on the server, save it locally and debug by replaying captured state.  See Analyze Plug-in Performance for more details.  The CRM SDK has a section on Debugging JavaScript in Microsoft Dynamics CRM.  If you are developing your CRM code using a Test Driven Development (TDD) approach with unit testing, then you might come to the same conclusion I came to in my Developing CRM 2011 customizations without a local server post.  My personal opinion is that unit testing makes the debugging process much better and improves overall developer productivity.  So what about using version control to manage your source code and other files?  Remember that most of your non-code customizations can be exported as part of CRM solution export as XML files.  I blogged about how to integrate the SolutionPackager tool from the CRM SDK into Visual Studio to source control non-code customizations to help you get started.

The SolutionPackager tool lays the foundation to enable you to build your application on a build server.  However, most people who go to the extent of using a build server also want more advanced build automation such as deploying to a test server or virtual environment.  While there’s a whitepaper called Deploying Microsoft Dynamics CRM 2011 and CRM Online Solutions from Development through Test and Production Environments which covers some of the nuances of such automation, it leaves much of the work to you to implement.  Thankfully, ADXStudio has built the Adxstudio ALM Toolkit which greatly decreases the time it will take a team to reach this level of automation.  Shan McCarthur delivered a fairly comprehensive webcast on team development that brings all the core topics together.  While the webcast is relatively ALM tool agnostic, it’s not a far leap to understand how use Visual Studio ALM tools after watching and having gone through the material in this post.

What about functional testing?  Unit testing is great and all, but not everyone is bought into TDD and unit testing.  I always tell people that unit testing doesn’t replace functional testing.  However, it usually DOES result in less bugs found during functional testing.  The Creating and Managing Tests section of the Visual Studio ALM documentation does a good job of navigating you through the different kind of functional testing it supports.  The little gem that I don’t think enough CRM projects are utilizing is Testing the User Interface with Automated UI Tests (aka Coded UI).  Dynamics CRM 2011 is one of the many Supported Configurations and Platforms for Coded UI Tests and Action Recordings.

And performance testing?  Performance testing is absolutely critical for any large scale software solution.  Not enough people do it.  The end result is usually finding issues in production when you go live.  UGH!  Performance testing can prevent lots of heartache.  The Visual Studio has tools to help you in your Testing Application Performance and Stress.  A compliment to Visual Studio is the Performance Toolkit for Microsoft Dynamics CRM 2011 which is just a set of guidance + additional tools which show you how to Visual Studio Stress Testing Tools with CRM.  Stress testing with CRM is a pretty specialized skill.  While I’ve given you pointers to the tools to do it yourself, you might want to consider the Microsoft Dynamics Benchmark offered by the Dynamics Premier Field Engineering (PFE) team at Microsoft.

@devkeydet

CRM Solution Manager keeps getting better

Full disclosure, I received a free license from the authors of the tool.  However, I do believe it’s definitely worth the license fee.

I’ve blogged previously about reasons for my fondness of the www.crmsolutionmanager.com addin to Visual Studio for Dynamics CRM 2011 development.  Well they’ve recently introduced some new features that I think make it an even more compelling alternative to the Developer Toolkit for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online.

@devkeydet

Improving the performance of multiple Inserts, Updates, and Deletes via the CRM 2011 Organization Service

UPDATE: Now that Polaris/UR12 are out, the new bulk API is available.  Check out Sonoma Partners blog post on a simple benchmark of the improvements.  Now you can Combine the ne bulk API with client side parallelism to achieve even better performance.  I’ll put that on my ever growing “to blog” list.  However, if you followed this post, then you should be able to figure it out yourself. 

UPDATE: Removed explicitly creating a ConnectionStringSettings object by calling CrmConnection.Parse().

If you are writing any .NET code that interacts with the Organization Service, any insert/update/delete performed happens one at a time, even if you call OrganizationServiceContext.SaveChanges().  This is a perfect candidate to improve performance using the Task Parallel Library.  Here’s a little code snippet to get you started:

var conn = CrmConnection.Parse("Url=https://YOURORG.crm.dynamics.com;Username=YOURUSERNAME;Password=YOURPASSWORD");
var ctx = new MyDataContext(new OrganizationService(conn));
 
var query = from a in ctx.AccountSet
            select new Account
            {                
                Id = a.Id,
                Name = a.Name,
                Address1_City = a.Address1_City
            };
 
var tasks = new List<System.Threading.Tasks.Task>();
var accounts = query.ToList();
 
foreach (var account in accounts)
{    
    // Parallelize each update until BulkAPI is released in UR12
    var task = System.Threading.Tasks.Task.Factory.StartNew(()=>{        
        ctx.Detach(account);
 
        account.Name += " - UPDATED";                
        account.Address1_City += " - UPDATED";    
 
        var newctx = new MyDataContext(new OrganizationService(conn));        
        newctx.Attach(account);
        newctx.UpdateObject(account);        
        newctx.SaveChanges();
    });
}
 
//Wait for all the updates executing in parallel to complete.
System.Threading.Tasks.Task.WaitAll(tasks.ToArray());

On my quad core laptop.  The serial version of this code takes a little over 5 seconds.   In comparison, the code above executes in less than a second.

@devkeydet