We help IT Professionals succeed at work.
Get Started

Microsoft CRM - Plugin debugging problem

225 Views
Last Modified: 2018-02-16
Hi, I am working on a complicated team project where I am not able to debug the code.  I am working with VS 2015 in a TFS environment and XrmToolKit to check in and build the plugin in CRM.

When attempting to debug a plugin, I get the attached message:
A project with an Output Type of Class Library cannot be started directly.
I have reviewed this with other developers on the team and they have had differing answers.  I need a way to set a breakpoint and step through the code to see what is not correct (missing quoteid, no guid, etc).

The answer I received was: Create a new .cs file in the unit test project to test code you want to implement.

Below is the code I was given for this process.  Set a break point where you want to debug the logic. Use the Test Explorer and locate your new .cs file.

using FakeXrmEasy;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using PACCAR_CRM_Code.Library;
using PACCAR_CRM_Code.Library.Result;
using PACCAR_CRM_Code.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Xml;
using Xunit;

namespace UnitTestProject
{
    public class Test
    {
        private static string OrgService = "http://spaceshuttle-test/LaunchTest";

        [Fact]
        public void Test_Debug()
        {
            var utilities = new Utilities();
            var ctx = new XrmFakedContext();
            var TracingService = new XrmFakedTracingService();
            var PIEventlog = new EventLog();
           

            //Establish Connection to CRM
            Uri organizatinUri = new Uri(OrgService + "/XRMServices/2011/Organization.svc");
            ClientCredentials credentials = new ClientCredentials();
            credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; //new NetworkCredential("zzitdrentestcrm", "d#!b28$Oe@E1b!");
            credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            OrganizationServiceProxy service = new OrganizationServiceProxy(organizatinUri, null, credentials, null);
            service.EnableProxyTypes();

            //Retrieve a quote for example
            Entity quote = service.Retrieve("quote", new Guid("YOUR GUID GOES HERE"), new ColumnSet(true));

            // Implement your Code here and use the quote above as the data if you require it
        


        }
    }
}

Open in new window

This is not working for me.  I get errors in the Error List and cannot get a clean build locally.  Basically I am not sure what code to put in where the example above says:   // Implement your Code here and use the quote above as the data if you require it

I was also told that I could use a windows forms application to debug, I am not sure how this would work but I assume it involve writing additional code.

I need advice on using either method to debug my code.  Right now I am building and publishing to see the results once I get a clean build locally.  This doesnt work because it introduces potentially bad code into CRM and TFS.

Thanks for your help.
Comment
Watch Question
Developer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE