“The application requires one of the following versions of the .NET Framework” or “.NET Framework 4.7.1 or later is already installed this computer” error while running application

While trying to run an application we were getting the below message

It was taking us to Microsoft Download site for downloading the framework.

We downloaded the 4.7.1 Framework but while trying to install it we got the below message that said the framework or a later update is already installed on this computer.

Tried uninstalling all the .NET Framework version installed including 4.7.

That also didn’t work.

Few of the forums talk about making changes in the registry, that also didn’t help.

Eventually we commented the supportedRuntime element in the configuration file of the application to get through this issue.



Hope it helps..


Literal Improvement in C# 7.0

C# 7.0 now allows using underscore _ to be used a digit separator.

This adds more readability.

Similarly, we now have Binary Literals, so instead of specifying hexadecimal pattern we can specify bit patterns.

Hope it helps..

Using Out Variables (C# 7.0) instead of Out Parameters

Out Parameters must need to declared before they are used in the method which doesn’t seem intuitive.

Now with C# 7.0 we can now make use of Out variable.

Here in our second call to the method we have used out variable named outVariableString which we didn’t have to declare like output parameter.

Hope it helps..

Tuple Types and Tuple Literals in C# 7.0

Tuple are used when we need to get more than one value returned from the method.

C# 7.0 introduces Tuple Types and Tuple Literals to Tuples

We need to add System.ValueType Nuget Package to add the required assemblies to Visual Studio.

Below sample code shows usage of Tuple type and literal. In our second method, we have named the part of the tuple i.e. name and number.

Now to access the first method we use Item1 and Item2 field, however for our second method as we have named the part we can use those names to access them i.e. name and number.

Output in both the case

Hope it helps..

New Feature – Local Functions in C# 7.0

C# 7.0 adds a new feature called local functions.

Local functions allow us to define function within a function. It can be used to write helper methods that we need to use inside that function’s scope.

Here in the below sample code we have defined one main function (MainFunction) that has one local function(MultiplyBy10LocalFunction) defined inside it. And that local function has one more local function(Add10LocalFunction) defined inside it.

Hope it helps..

Using FormFlow in Microsoft Bot Framework (Creating lead in CRM)

Let us continue with our previous posts on using Microsoft Bot Framework

Getting Started with Microsoft Bot Framework.

Using Dialogs in Microsoft Bot Framework

To better understand the FormFlow refer to the below article.


Here we will update our Bot Application to use the FormFlow instead of Dialog.

As FormFlow are bound to a model, we will create a model class first.

Create a new folder named Model and a new class named LeadModel in it.

The class has an enum for selecting Product Type. It defines property for capturing Name and Description.

Here we define a static method named BuildForm that returns the IForm of type LeadModel.

The message defines the initial message that will be shown to the user and oncompletion we are defining a callback method that will be called on completion which we will be using to create lead record in CRM.

Next update the MessageController.cs to call this Lead Model instead of dialog which we did in our previous post.

The conversation between the Bot and the User.

The lead record created in CRM.

Source Code –

using Microsoft.Bot.Builder.FormFlow;
using System;
using Microsoft.Bot.Builder.Dialogs;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk;

namespace Bot_Application1.Models

public enum InterestOptions { Product1 = 1, Product2 = 2, Product3 = 3};

public class LeadModel
public InterestOptions Product;
public string Name;
public string Description;
public static IForm<LeadModel> BuildForm()
return new FormBuilder<LeadModel>()
.Message("Welcome to the CRM bot !")
private static async Task CreateLeadInCRM(IDialogContext context, LeadModel state)
await context.PostAsync("Thanks for showing your interest we will contact you shortly.");
Entity lead = new Entity("lead");
lead.Attributes["subject"] = "Interested in product " + state.Product.ToString();
lead.Attributes["lastname"] = state.Name;
lead.Attributes["description"] = state.Description;

public static OrganizationServiceProxy GetOrganizationService()
IServiceManagement<IOrganizationService> orgServiceManagement =
ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://nishantcrm365.crm.dynamics.com/XRMServices/2011/Organization.svc"));
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials.UserName.UserName = "nishant@nishantcrm365.onmicrosoft.com";
authCredentials.ClientCredentials.UserName.Password = *****";
AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
return new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);

using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.FormFlow;
using Bot_Application1.Models;

namespace Bot_Application1
public class MessagesController : ApiController
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task Post([FromBody]Activity activity)
if (activity.Type == ActivityTypes.Message)
// call MyDialog
// await Conversation.SendAsync(activity, () => new Dialogs.MyDialog());

// Call our FormFlow by calling MakeRootDialog
await Conversation.SendAsync(activity, MakeRootDialog);

var response = Request.CreateResponse(HttpStatusCode.OK);
return response;

internal static IDialog<LeadModel> MakeRootDialog()
return Chain.From(() => FormDialog.FromForm(LeadModel.BuildForm));

private Activity HandleSystemMessage(Activity message)
if (message.Type == ActivityTypes.DeleteUserData)
// Implement user deletion here
// If we handle user deletion, return a real message
else if (message.Type == ActivityTypes.ConversationUpdate)
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
else if (message.Type == ActivityTypes.ContactRelationUpdate)
// Handle add/remove from contact lists
// Activity.From + Activity.Action represent what happened
else if (message.Type == ActivityTypes.Typing)
// Handle knowing tha the user is typing
else if (message.Type == ActivityTypes.Ping)

return null;

The next posts in this series

Hope it helps