Skip to main content

Posts

Showing posts from October, 2013

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Today while working suddenly my laptop crashed and restarted again. Once laptop restarted, I opened the project in Visual Studio 2012 and tried to run my application, but I got weird Assembly Load Error: Could not load file or assembly...: Full error read as: Could not load file or assembly ‘AjaxControlToolkit’ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0×80070057 (E_INVALIDARG)) I tried to clean and rebuild my application, and even closed and re-open visual studio, but still I faced the same error. Even I removed the assembly reference of 'AjaxControlToolkit' and added reference back to my application, but still no luck. After some research I found out that AjaxControlToolkit assembly corrupted in Temporary ASP.NET Files folder, due to which it is throwing error. Solution:   ·          Close all instances of Visual Studio.   ·        ...

LINQ to Entities does not recognize the method 'Boolean like String (System.String)' method, and this method cannot be translated into a store expression.

While working with LINQ queries (IQueryable<T>) one may face the error of 'LINQ to Entities does not recognize the method...’ For example consider following LINQ statement: dbContext.Employees .Where(c => ! string .IsNullOrWhiteSpace(c.Name)); There will be not any compile error and it'll be compiled successfully, however you'll get the error (mentioned below) when this query get executed. "LINQ to Entities does not recognize the method 'Boolean IsNullOrWhiteSpace(System.String)' method, and this method cannot be translated into a store expression." Reason: Once you get the error, you'll try to figure out what went wrong with this LINQ statement, as there is no error if you compile the above statement. Simple reason of this error is IQueryable<T> creates the SQL friendly query and once you enumerate (i.e. by accessing any property or converting it into IEnumerable<T> or List) over this query it...

C#: How to format a Numeric String or Decimal as Currency

In this topic I will show examples on how to format your string, decimal/double or integer value in currency with C#. While working on any application it is always good to show user more human friendly money format rather than showing simple value. Formatting currency is quite easy with C#. We’ll use the standard Currency (“C”) Format Specifier, it works like this: {0:C}. //declare amount. decimal amount = 1704.40m; string currency = string .Format( " {0:C} " , amount); We can get same result with the help of ToString() method like: string currency = amount.ToString( "C" ); Output in both case will be: $1,704.40 We can also get output in different currency symbol (e.g. ₹ $ £ ₩ € etc.) using culture information. With the help of “ CultureInfo .CreateSpecificCulture( "culuture-name" ) “ one can set the culture information, and can print the price with the proper currency symbol. For example: ...

SignalR Tutorial: Your first SignalR chat application with ASP.net MVC 4

In last post I explained what SignalR, why do us need it is and what are the prerequisites. In this tutorial we’ll use ASP.NET SignalR to create a real-time chat application. First of all we’ll add SignalR library to an MVC 4 application and then create hub class (to push content to client) and after that we’ll use SignalR jQuery library to send messages and display updates from the hub. ·          Open Visual Studio -> Select ASP.NET MVC4 Web Application template (under Web Templates) and enter the name of application as “MVCSignalRApp” and then click OK. ·          On the next screen select “Internet Application” template and then click OK. ·          Your basic MVC application is ready to use, now we need to add SignalR libraries to this application. To add SignalR libraries open Package Manager Console (TOOLS - >Library Package M...