Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug where opening a connection after the plugin is open, results in a null ref error #236

Merged
merged 4 commits into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed bug where if all events were being removed from a form, the eve…
…nts node wasn't getting removed.
  • Loading branch information
daryllabar committed Sep 17, 2015
commit ef29aab4165788d10a07420453bb5b91554230b1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Without GemBox|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug Without GemBox\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy">
<HintPath>..\..\Referenced Assemblies\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
Expand Down Expand Up @@ -105,7 +114,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_ConfigurationName="Release" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.YearStamp.MonthStamp.DayStamp" />
<UserProperties BuildVersion_BuildVersioningStyle="None.YearStamp.MonthStamp.DayStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_ConfigurationName="Release" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,48 @@ public bool RemoveLibrary(Entity form, string libraryName, Form parentForm)
}

// Retrieve events that use the library
var eventNodes = formNode.SelectNodes(string.Format("events/event/Handlers/Handler[@libraryName='{0}']", libraryName));
if (eventNodes != null && eventNodes.Count > 0)
{
var result =
MessageBox.Show(parentForm,
string.Format(
"The library '{2}' is used by {0} event{1}. If you remove the library, {0} event{1} will be removed too\r\n\r\nDo you want to continue?",
eventNodes.Count, eventNodes.Count > 1 ? "s" : "", libraryName), "Question", MessageBoxButtons.YesNo,
var handlerEventNodes = formNode.SelectNodes(string.Format("events/event/Handlers/Handler[@libraryName='{0}']", libraryName));
if (handlerEventNodes != null && handlerEventNodes.Count > 0)
{
var result = DialogResult.None;
parentForm.Invoke((MethodInvoker)delegate {
result = MessageBox.Show(parentForm, string.Format(
"The library '{2}' is used by {0} event{1}. If you remove the library, {0} event{1} will be removed too\r\n\r\nDo you want to continue?",
handlerEventNodes.Count, handlerEventNodes.Count > 1 ? "s" : "", libraryName)
, "Question", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
});

if (result == DialogResult.No)
{
return false;
}

// Remove events that were using the library
foreach (XmlNode handlerNode in handlerEventNodes)
{
// Events> <Event> <Handlers><Handler>
if (handlerNode.ParentNode.ChildNodes.Count == 1)
{
var events = formNode.SelectSingleNode("events");
if (events.ChildNodes.Count == 1)
{
// Remove Events since it only has one Event and the Event only has on handler, and the Handler is getting removed
events.ParentNode.RemoveChild(events);
}
else
{
// Remove Event since it only has one handler and it is being removed, but there are other events
events.RemoveChild(handlerNode.ParentNode.ParentNode);
}

}
else
{
// Remove only handler since there are other handlers
handlerNode.ParentNode.RemoveChild(handlerNode);
}
}
}

var formLibrariesNode = formNode.SelectSingleNode("formLibraries");
Expand All @@ -148,7 +176,7 @@ public bool RemoveLibrary(Entity form, string libraryName, Form parentForm)
var libraryNode = formLibrariesNode.SelectSingleNode(string.Format("Library[@name='{0}']", libraryName));
if (libraryNode == null)
{
throw new Exception("This library is noy included in this form");
throw new Exception("This library is not included in this form");
}

// Remove library
Expand All @@ -159,19 +187,6 @@ public bool RemoveLibrary(Entity form, string libraryName, Form parentForm)
formLibrariesNode.ParentNode.RemoveChild(formLibrariesNode);
}

// Remove events that was using the library
foreach (XmlNode eventNode in eventNodes)
{
if (eventNode.ParentNode.ChildNodes.Count == 1)
{
formNode.SelectSingleNode("events").RemoveChild(eventNode.ParentNode.ParentNode);
}
else
{
eventNode.ParentNode.RemoveChild(eventNode);
}
}

// Update the form xml content
form["formxml"] = formDoc.OuterXml;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ private void tsbRemoveCheckedScripts_Click(object sender, EventArgs e)
WorkAsync("Updating forms...",
(bw, evt) =>
{
var scripts = (List<Entity>)((object[])evt.Argument)[0];
var forms = (List<Entity>)((object[])evt.Argument)[1];
var argArray = (List<Entity>[]) evt.Argument;
var scripts = argArray[0];
var forms = argArray[1];


var fManager = new FormManager(Service);

Expand Down Expand Up @@ -307,7 +309,7 @@ private void tsbRemoveCheckedScripts_Click(object sender, EventArgs e)
}
},
evt => SetWorkingMessage(evt.UserState.ToString()),
new[] { scriptsParam, formsParam });
new [] { scriptsParam, formsParam });
}
}
}
9 changes: 9 additions & 0 deletions Plugins/MsCrmTools.FormRelated/MsCrmTools.FormRelated.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Without GemBox|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug Without GemBox\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy">
<HintPath>..\..\Referenced Assemblies\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Without GemBox|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug Without GemBox\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy">
<HintPath>..\..\Referenced Assemblies\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
Expand Down
9 changes: 9 additions & 0 deletions XrmToolBox.Extensibility/XrmToolBox.Extensibility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Without GemBox|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug Without GemBox\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy">
<HintPath>..\Referenced Assemblies\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
Expand Down
20 changes: 10 additions & 10 deletions XrmToolBox.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XrmToolBox", "XrmToolBox\XrmToolBox.csproj", "{328D55BE-8B9A-4087-A5C2-9FBAF623F54B}"
EndProject
Expand Down Expand Up @@ -504,8 +504,8 @@ Global
{236F1329-C748-4C01-948B-98AE9EA89086}.Release|x86.ActiveCfg = Release|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Any CPU.ActiveCfg = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Any CPU.Build.0 = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug Without GemBox|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug Without GemBox|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug Without GemBox|x86.ActiveCfg = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -519,8 +519,8 @@ Global
{5244E9BE-820A-4613-8ACC-ADC858B83C26}.Release|x86.ActiveCfg = Release|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Any CPU.ActiveCfg = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Any CPU.Build.0 = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug Without GemBox|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug Without GemBox|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug Without GemBox|x86.ActiveCfg = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -534,8 +534,8 @@ Global
{DF77AEA3-43F7-403C-91AF-3023A3BB06EC}.Release|x86.ActiveCfg = Release|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Any CPU.ActiveCfg = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Any CPU.Build.0 = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug Without GemBox|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug Without GemBox|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug Without GemBox|x86.ActiveCfg = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -549,8 +549,8 @@ Global
{28F6D950-BC28-4067-98AF-5D6AE70E90A7}.Release|x86.ActiveCfg = Release|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Any CPU.ActiveCfg = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Any CPU.Build.0 = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Mixed Platforms.ActiveCfg = Debug Without GemBox|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|Mixed Platforms.Build.0 = Debug Without GemBox|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug Without GemBox|x86.ActiveCfg = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACC1243E-912B-45E7-A8B0-E312EE9141DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand Down
9 changes: 7 additions & 2 deletions XrmToolBox/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
Expand Down Expand Up @@ -281,10 +282,14 @@ private async void MainForm_Load(object sender, EventArgs e)

var tasks = new List<Task>
{
this.LaunchWelcomeDialog(),
this.LaunchVersionCheck()
this.LaunchWelcomeDialog()
};

if (!Debugger.IsAttached)
{
tasks.Add(this.LaunchVersionCheck());
}

if (!string.IsNullOrEmpty(this.initialConnectionName))
{
var connectionDetail = ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(x => x.ConnectionName == this.initialConnectionName); ;
Expand Down