Saturday, August 15, 2015

Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'

Exception:
Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider' from assembly 'Microsoft.SharePoint.WorkflowServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' does not have an implementation.

We continuously faced a serious problem in SharePoint 2013 workflow development after installing the hotfix- KB2880998.  This hotfix causes different types of problem in Workflow Manager 1.0. 

Initially we did not identified the root cause. We thought that this was may some server related issue occurred by our last deployment in DEV server. But our Staging server also effected with the same error since we did not deployed our changes to that server. 

Closely observe the ULS logs it seems that this causes by some workflow related dll missing or corrupted. Then investigating the issue based on workflow related issue and found the following link which described the issue clearly

https://social.technet.microsoft.com/Forums/windowsserver/en-US/b189e4b8-bb9e-4ade-a3d5-cd2e0f90e93f/workflow-not-working-after-installing-service-pack-1-and-patches?forum=sharepointadmin

Solution:

Install the security update 2880963 for SharePoint Server 2013 from the following link will fix the issue.


Method 'Upgrade' in type 'Microsoft.SharePoint.WorkflowServices.WorkflowServiceApplicationProxy'

Method 'Upgrade' in type 'Microsoft.SharePoint.WorkflowServices.WorkflowServiceApplicationProxy' from assembly 'Microsoft.SharePoint.WorkflowServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' does not have an implementation.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.TypeLoadException: Method 'Upgrade' in type 'Microsoft.SharePoint.WorkflowServices.WorkflowServiceApplicationProxy' from assembly 'Microsoft.SharePoint.WorkflowServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' does not have an implementation.

Recently we have installed service pack-1 for SharePoint server  2013. Everything is going well but development team face the above mentioned issue during custom workflow development. 

After investigating we found that Service Pack-1 unstable the Workflow service. Microsoft release a patch to fix the workflow related issue.

Solution:

The workflow upgrade issue required STS and OServer are at the same version. Following update link provide by Microsoft described the issue and fixing.

https://support.microsoft.com/en-us/kb/2880963

Install the following security patch will fix the reported issue.
FYI: No need to restart the SharePoint server 2013 after install the update.

Friday, August 7, 2015

Problem:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.SharePoint.WorkflowExtensions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.SharePoint.WorkflowExtensions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Causes/Solutions:
Our team faced this exception for several scenarios in Development environment. We fixed this problem in different combination for different scenarios.

Development Environment:
Windows server 2012
Visual Studio 2012
SharePoint Server 2013,
SharePoint Workflow 2013

Cause-1:
Workflow Manager Tool was not installed.

Solution-1:
Simply installed the workflow manager tools for SharePoint Workflow 2013.

Cause-2:
Workflow Manager Tool was installed but not updated with corresponding Cumulative update.

Solution-2:
As we know SharePoint workflow is managed by Workflow Manager 1.0 and its depends upon Service Bus 1.0. So need to update both version as well.
These two cumulative updates were working for us.

February 2013 Cumulative Update for Service Bus 1.0: KB2799752
February 2013 Cumulative Update for Workflow Manager 1.0: KB2799754

Cause-3:
Office Developer Tools (OfficeDevToolsforVS2012) was not installed on the DEV box.

Solution-3:
Installed the correct version of Office developer tools. We need to installed the OfficeDevToolsforVS2012 version.

Hopefully this will be helpful for other.

Thursday, June 13, 2013

Technical Reviewer of a new book "Razor View Engine How-to"


Packt Publishing recently released a new book titled – Instant Razor View Engine authored by Abhimanyu Kumar Vatsa. I  have also attached with this process as a technical reviewer.

The main aspect of this book is to made easy for the developers to understand the use of razor view engine in ASP.net MVC. I found this book very helpful for beginner because it shows differences between different scenario with code example. It also covers differences between ASP.net view engine and razor view engine.

This book guide developer a step by step procedure to learn razor view engine quickly and effectively. For advanced developers it also covers the custom model binding,Razor helper extension method,declarative syntax etc.

Friday, November 16, 2012

Observer Design Pattern using Delegates/events

Today I want to discuss with you how to implement Observer design pattern using delegate and event in asp.net /c#.

Observer Pattern

The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems. The Observer pattern is also a key part in the familiar Model View Controller (MVC) architectural pattern.(wikipedia).

UML class diagram of Observer pattern(wikipedia)





The Observer Pattern describes the dependence relationship between one object (observable) to many objects (observers). It's also called Model/View, Dependents, or Distributor/Listener pattern.This article introduces an implementation when we can use the Observer pattern to keep all observer objects updated after things have changed.

Case project

In this case, patient is an ObservableObject that needs to send out the notification when the hospital updates his/her physical status. The hospital will determine who will be notified when the patient status is updated.

Thursday, November 15, 2012

A Custom Attribute based approach to write summary on business object

Last day, I have got a mail from a junior developer he needs some help about custom attributes. He has no previous experience about it. I have delivered his some speech or send some link for study. Today I have made an example for him, so that he can understand its usage very easily. Now this also share with you it may also help other friends.


using System;
using

Tuesday, October 9, 2012

MSSQL SERVER 2008 – IntelliSense Does Not Work

Last few months ago I have upgraded Visual Studio 2010 ultimate with service pack 1. But unfortunately my SQL Server Management Studio(SSMS) 2008 intellisense not working. After searching I got that it is a common problem. Please have visit here.

To fix it just install SQL Server 2008 r2 SP1. You can download it from here.

If it is not working please check the following issues it may solve your problem.

  • Verify that the T-SQL Editor does not launch in SQLCMD mode Under Tools->Options->Query Execution->SQL Server->General, make sure “By default, open new queries in SQLCMD mode” is unchecked.

Thursday, September 27, 2012

“The ‘VSTS for Database Professionals Sql Server Data-tier Application’ package did not load correctly”

After long time, I have got some relax from work pressures. I have got lots of mail about several issues. I had tried to give them hot fix with in a very short time. Sorry to everyone for my late response.

Today, when I am setting my new laptop I have faced a problem in VS 2010. Just run the VS2010 and got the error,
The ‘VSTS for Database Professionals Sql Server Data-tier Application’ package did not load correctly.
I don't understand why this is happening?

Potential cause:
This problem may occur due to install SQL Server Express 2008 with Visual Studio 2010 installation. When install SQL Server 2008 r2 on the same machine I had got an exception. So that I have uninstalled SQL Server Express 2008 from machine and then install SQL Server 2008 r2 but installation not completed successfully.

Solution 1:
I have got the solution from this link.
To fixed my problem I did the following tasks

Step-1: Run the Visual Studio 2010 Ultimate  disc
Step-2: Explore  \WCU\DAC folder from disc
Step-3: Now installed the three packages from the Visual Studio 2010 Ultimate disc and it fixed the problem right away for me.

Microsoft SQL Server 2008 R2 Data-Tier Application Framework with this command:
\WCU\DAC\DACFramework_enu.msi

Microsoft SQL Server 2008 R2 Data-Tier Application Project:
\WCU\DAC\DACProjectSystemSetup_enu.msi

Microsoft SQL Server 2008 R2 Transact-SQL Language Service:
\WCU\DAC\TSqlLanguageService_enu.msi

If required you can re-install the Visual Studio 2010 Service pack 1.

Thursday, August 16, 2012

KeyValue pair/Dictionary with duplicate keys

Very recently for my development purpose I need to use Dictionary. And it works very nicely. But problem occurred when requirement changes and face a scenario that duplicate key's are needed to handle in Dictionary which is not possible. So I had written a custom class to handle this problem,please suggests me if there is any better idea.

Examble:

public class KeyValuePair
{
public string Key { get; set; }
public int Value { get; set; }
public string HdValue { get; set; }

public KeyValuePair(string key, int value, string hdValue)
{
this.Key = key;
this.Value = value;
this.HdValue = hdValue;
}
}

Insert Data:
List<KeyValuePair> listKeyValuePair= new List<KeyValuePair>();
listKeyValuePair.Add(new KeyValuePair("TAX",2,"Income Tax"));
listKeyValuePair.Add(new KeyValuePair("TAX",4,"Vatlue added Tax"));
listKeyValuePair.Add(new KeyValuePair("PORT",9,"Vehicle Test"));


Sort Data:
List<KeyValuePair> listSorted = listKeyValuePair.OrderByDescending(x => x.key).ToList();


Filter Data:
var filteredData = listKeyValuePair.where(keyValue=> string.Compare(keyVaue.Key,"TAX")==0).ToList();
if(filteredData.Count > 0)
{
//Do something
}

Wednesday, August 15, 2012

Short circuit evaluations on && and || in JavaScript

Like many other languages Javascript’s && and || operators short-circuit evaluations,that is, for

&& if the first operand evaluates to false, the second operand is never evaluated because the result would always be false.
Similarly, for
|| if the result of the first operand is true, the second operand is never operated.

This means that in the following expression, x will never be compared to y.
true || x == y

This short-circuiting is great for performance, as it allows significant bits of calculations to be skipped. In addition to that, it lets you to write e.g. the following in one expression without getting an ‘object has no properties’ error:
oNode && oNode.firstChild

Be mindful though when using && with code that has side effects, e.g. say you have two objects with a hasError() method which return true or false depending on whether an error occurred and additionally output an error message:
x.hasError() && y.hasError()

Here, if x has an error, y will never be evaluated and thus the error message will never be shown.

For more details pls visits this and that.

Monday, July 2, 2012

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Very recently I got a mail from a junior guy he faced a problem every time when he installed the SQL server database on his workstation. But he failed to understand what is the main reason behind this. The problem was that after installing SQL server database his working web sites were throws exception like this...

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Reason
The main reason behind this error occurs when you configured your web site with IIS. When any one tries to browse the site, IIS send the request to the SQL server with credentials. But unfortunately the credential do not have proper permission. So that it throws exception.

Solution
We can solve this problem in several ways....
First solution that resolved my problem was:

  1. Login to SQL server database via SQL Server Management Studio
  2. Go to the "Security" directory of desired database
  3. Right-click the Users directory
  4. Select "New User..."
  5. Add 'NT AUTHORITY\NETWORK SERVICE' as a new user
  6. In the Data Role Membership area, select db_owner
  7. Click OK

Monday, May 28, 2012

Custom paging,sorting and filtering data with Dynamic query

Sometime it becomes very essential for us to write dynamic query for custom paging,sorting and filtering data. Today I want to share simple one which may help others to fulfill their requirements.


Sample stored procedure:


CREATE PROCEDURE [dbo].[spGetAllTag]
@SearchText varchar(50),
@PageIndex INT = 1,//page number like 1,2,3
@PageSize INT =10,
@SortCol varchar(100),
@TotalCount int output
As
Begin

;WITH PagingCTE (Row_ID,ID,Tags,Weight,CreatedBy)
     AS
      (
      SELECT
            ROW_NUMBER()
                  OVER(ORDER BY
                         CASE WHEN @SortCol='Name DESC' THEN [NAME] END DESC,
                         CASE WHEN @SortCol='Name ASC'  THEN [NAME] END ASC,
                         CASE WHEN @SortCol='CreatedBy DESC' THEN CreatedBy END DESC,
                         CASE WHEN @SortCol='CreatedBy ASC'  THEN CreatedBy END ASC,
                         CASE WHEN @SortCol='Weight ASC'   THEN Weight  END ASC,
                         CASE WHEN @SortCol='Weight DESC'  THEN Weight  END DESC

                        ) AS [Row_ID],
ID,
[NAME],
Weight,
CreatedBy

FROM TabularWeight
WHERE [Name] LIKE @SearchText + '%'
         )

       SELECT
            Row_ID,
            ID,
            [NAME],
            Weight,
            CreatedBy
         
      FROM PagingCTE
      WHERE Row_ID >= (@PageSize * @PageIndex) - (@PageSize -1) AND
            Row_ID <= @PageSize * @PageIndex

select @TotalCount = count(1) from dbo.TabularWeight where [Name] LIKE @SearchText + '%'  
   
End
GO

Friday, April 27, 2012

How can I get a value of a property from an anonymous type (C#)

Last day I have faced a problem when working with  "Anonymous Type". In development procedure I have got  result from a service which return object made of anonymous type. The problem arise when I need to access property of anonymous type. After made some r&d I have got the solution. Now share with you ....

Solution 1: (use reflection to retrieve the values of the following anonymous type)


var obj = new { ClientId = 7, ClientName = "Ahsan", Jobs = 12,City="Dhaka" };
System.Type type = obj.GetType();
int clientid = (int)type.GetProperty("ClientId").GetValue(obj, null);
string clientname = (string)type.GetProperty("ClientName").GetValue(obj, null);
// clientname  return the result Ahsan

More generic solution:

public static T GetValueFromAnonymousType( object dataitem, string itemkey ) 
{
    System.Type type = dataitem.GetType();
    T itemvalue = (T)type.GetProperty(itemkey).GetValue(dataitem, null);
    return itemvalue;
}

Example:
 var obj = new { ClientId = 7, ClientName = "Ahsan", Jobs = 12,City="Dhaka" };
 string clientname = GetValueFromAnonymousType(obj, "ClientName");



Solution 2:

var obj = new { ClientId = 7, ClientName = "ACME Inc.", Jobs = 5 };
string clientname = TypeUtils.GetValueFromAnonymousType(obj, "ClientName");

var obj = new { ClientId = 7, ClientName = "ACME Inc.", Jobs = 5 };
Type t = obj.GetType();

//Then from that you look up a property:
PropertyInfo p = t.GetProperty("ClientName");

//Then from that you can get a value:
object v = p.GetValue(obj, null);

//This answer is long overdue for an update for C# 4:
dynamic d = obj;
object v = d.ClientName;

Hope that it may helpful for others.
Thanks

Monday, April 2, 2012

2012 Microsoft® MVP Award

Last night I have got this mail from Microsoft MVP award program manager.

“Dear Ahsan Murshed,

Congratulations! We are pleased to present you with the 2012 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in ASP.NET/IIS technical communities during the past year.”


Alhamdulillah,I am pleased to say that Microsoft has re-awarded me Microsoft MVP status again for 2012! This is my second consecutive MVP award, this year for Microsoft ASP.NET/IIS. I am really proud about this. This reward obviously motivated me to give more effort for community.

Tuesday, March 13, 2012

The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

Today I have faced a problem when working with a previous developed ASP.NET MVC application. Just copy the database(.sdf) from previous version to new version. I have changed some validation and business logic. But when run the application it shows me the following error:


The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.


It was a running application after searching on community I have got the solution.

Solution 1:
However, even if you manually update the database to follow the model, this exception will still occur. The reason is that EF does not check model schema completely: tables, columns, keys, indexes etc.

It calculates a hash of the model and compares with the hash of model which the database was built with. The hash is stored at EdmMetadata table.

Monday, March 12, 2012

ASP.NET Single Page Application (SPA)

My previous article wrote about new features of MVC 4.0 beta. Today I want to share with you another cool feature "ASP.NET Single Page Application (SPA)" known as ASP.NET SPA.
The ASP.NET Single Page Application (SPA) is a new feature in MVC 4 beta preview.

This project type is based on a stack of open source libraries and the MVVM pattern made popular by WPF and Silverlight. Single Page Application(SPA) Frameworks are growing popularity in the web community with lot of libraries such as JavaScriptMVC, Backbonejs and many other libraries.

(Img src: asp.net official site)


ASP.NET MVC 4 introduces experimental support for building single page application (SPA) through a template. Much of the plumbing work of wiring up the client side scripts, javascript modelviews and the controllers is automated, making it a quick start to develop SPAs relatively easier.

The ASP.NET Single Page Application (SPA)includes the following components:

1.A set of JavaScript libraries for richer local interactions with cached data
2.Additional Web API components for unit of work and DAL support
3.An MVC project template with scaffolding to get started quickly

For more info:http://www.asp.net/single-page-application

New cool features in MVC 4.0

Last few days I have worked on MVC3 and MVC4 beta. In MVC4 beta some cool features added like:

1.ASP.NET Web API
2.ASP.NET Single Page Application
3.Enhancements to Default Project Templates
4.Mobile Project Template


5.Display Modes

Friday, March 2, 2012

Error: Unable to Validate Data

Recently I have made some changes on my application after upload I have found this error:

Unable to validate data at
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier,
Int32 start, Int32 length, Int32& dataLength) at
System.Web.UI.LosFormatter.Deserialize(String input)

But I don't understand why this error was happening. Because I have changed on business logic not any architecture. After doing some r&d got the answer:)


Potential causes:

1.An application pool recycling between the time the viewstate was generated and the time that the user posts it back to the server (unlikely).
2.Modification of viewstate by firewalls/anti-virus software
3.A web farm where the machineKeys are not synchronized (not your issue).
4.Posting from one aspx page to another.

After studying various tutorial I have found that the problem is with the viewstate. The viewstate is actually decrypted in the server using a secret Machine key which resides on the server. The interesting thing is the key gets regenerated after a certain time. Therefore when the user returns the viewstate, if the machine identified key is changed, the decryption of viewstate fails and thus throws this nasty error.

Solution 1:

The solution is simple. First of all, to solve the issue, I disabled the ViewState for the current page by putting EnableViewState = false. I even disabled this for the entire viewstate for the website using Web.config. But still the error.

Finally I used "EnableViewStateMac =false" in pages section.this cause the problem.

<pages buffer="true" enableViewStateMac="flase"/>
</pages>


Just place the following between the system.web section and the site starts working.

Solution 2:

Second solution that we might use as well is to place the machine key directly on our web.config, so that it always decrypts and encrypts using the static key values. To do this, we need to use the following:

<machinekey validationkey="22E995276703B846C4AD0881EE3159FFCB376CD48B27F64
9A074815C83D5C925038938F6943555687582CBC186DB22E552FCDB4D46
124BAADEE85A857CC135BC"
decryptionkey="60588EB661A6483348C20F92659775872CB06427AF20733C"
validation="SHA1"></machinekey>


You can also try to use this site to generate validation key.

Viewstate & Machine config interaction:

When a request for a page in the server. After you place the request the server processes it, encrypts the viewstate that the server receives using the encryption mentioned. Basically it uses the key mentioned in the Machine.config to encrypt the viewstate data. Finally it converts to Base64 and embeds into some hidden fields.

We can mention the machine key in Web.config too so that it uses it for the current website. You might use the AutoGenerate option too to enable/disable autogeneration of key during runtime.
For more information visits.

For further study please visits: MS article

Orchard 1.4 Is released!!

Last day officially announced that the new Orchard release - version 1.4. It's a big step forward from the previous, 1.3.10 version, both in terms of performance and features.

Orchard 1.4 is here! The release is published on our Orchard CodePlex website and Microsoft Web Application Gallery.


What's new?

Orchard 1.4.0 fixes bugs, improves performance and introduces the following features:

Autoroute: Set-up token-based patterns for your URLs. David Hayden has a good post describing the feature: http://www.davidhayden.me/blog/autoroute-custom-patterns-and-route-regeneration-in-orchard-1.4

Projector: Create arbitrary queries on your site contents, then display the results in projection pages and widgets.

Fields: Orchard now comes with new field types for Boolean, Date/Time, Enumeration, HTML5 Input, Links, Media Picker and Numeric. The text field has a new setting for the flavor which adds html, markdown and textarea to the default text box.


Breaking Changes

Orchard 1.4 introduces a breaking change with the Autoroute and Alias features by removing the Route part that was previously handling URLs and titles for content items.

Migrating existing content items can be done with a special module (see next section), but it may also happen that some modules that were relying on the presence of Route may stop working.

We've asked all module developers to review their code with the new version, but there may still be incompatible ones out there. If a module misbehaves, please check whether a new version is available. If there isn't one, please contact its author through the contact form on the Orchard Gallery.

You may also attempt to fix the modules you need: we have a set of instructions on this thread.

Friday, February 10, 2012

How to convert List to DataTable

very recently I have published a new article based on "How to convert DataTable to generic List"

Now I have discussed about the vice verse -"convert List to DataTable"

Solution:

Here we use PropertyDescriptor ComponentModel class.

public static DataTable ToDataTable<T>(this IList<T> data)
{
PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(typeof(T));
DataTable table = new DataTable();
foreach (PropertyDescriptor prop in properties)
table.Columns.Add(
prop.Name,
(prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
? Nullable.GetUnderlyingType(prop.PropertyType)
: prop.PropertyType
);
foreach (T item in data)
{
DataRow row = table.NewRow();
foreach (PropertyDescriptor prop in properties)
row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
table.Rows.Add(row);
}
return table;
}

Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'

Exception: Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'...