(Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Most often when you checkout old git repo or your own code stashed for months, and compile, you will encounter this exception

(Exception from HRESULT: 0x80070057 (E_INVALIDARG))

This could be because project can’t find references or some other updated dlls are not causing issue with ones already in a compiled code.

Simplest way to fix this is to .. delete the ‘bin’ and ‘obj’ folders of the project and if it is web project, delete ‘Temporary ASP.NET Files’

Hope that helps :)

Unable to retrieve metadata for ‘some entity class’. Unable to load the specified metadata resource.

Sometimes when we are using Entity Framework with MVC, we update the datamodel to add/update/remove entities. When we try adding controller, we get the following error.

There was an error running the selected code generator:

‘Unable to retrieve metadata for ‘some entity class’. Unable to load the specified metadata resource.’

Easiest fix for this, in web.config, for the database connection string, you will find the string as below

metadata=res://*/ModelName.csdl|res://*/ModelName.ssdl|res://*/ModelName.msl;provider=

Replace it with

metadata=res://*/;provider=…

Compile once and retry adding the controller.

This is quick fix and works :)

P.S. Ideally we should remove the connectionstring and edmx file and add it again to make it work.

Windows Phone emulators stuck at ‘OS is loading’ or ‘Loading Operating System’ or ‘Windows Phone OS is starting…’

Many a times, Windows Phone Emulators fail to launch and usually are stuck at ‘OS is loading’ or ‘Loading Operating System’ or ‘Windows Phone OS is starting…’. Simple fix for this is to go to ‘Control Panel’ -> ‘System and Security’ -> ‘Windows Firewall’ -> ‘Allow app or feature through Windows Firewall’, and add app found at C:Program Files (x86)Microsoft XDE<version>XDE.exe to allow list.

Simple isn’t it?

 

Don’t let your server response headers reveal too much about your server!

On every request on API or a website, your server sends some information that might hurt your servers, if vulnerabilities are discovered on specific version of IIS, MVC version, .Net framework. Below are sample response headers that reveal too much about your server.

Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

Lets figure out a way to hide them

Server: Microsoft-IIS/8.0

Add these lines to global.asax

protected void Application_BeginRequest(object sender, EventArgs e)
{
var application = sender as HttpApplication;
if (application != null && application.Context != null)
{
application.Context.Response.Headers.Remove(“Server”);
}
}

X-AspNetMvc-Version: 4.0

If it is MVC / MVC WebAPI project reveals  You can hide it by adding these lines in Global.asax 

protected void Application_Start()
{
MvcHandler.DisableMvcResponseHeader = true;
}

X-AspNet-Version: 4.0.30319

Add these lines to Web.Config

<system.web>
<httpRuntime … enableVersionHeader=”false” /> …

 X-Powered-By: ASP.NET

Add these lines to Web.Config

<system.webServer>
<httpProtocol>
<customHeaders>
<remove name=”X-Powered-By” />
</customHeaders>
</httpProtocol>

Hope that helps :)

[Issue => Fix] Stuck at Authenticating with the iTunes Store

Many a times, while pushing the iOS app to Apple App Store, when we use Application loader, we get stuck at message ‘Authenticating with the iTunes Store.

Quickest fix for this is to copy ‘Application Loader’ app from ‘Applications’ to desktop, and simultaneously running both ‘Application Loader’ apps, one from ‘Applications’ folder and one from desktop to publish to app store. This works like charm every time.

Hope that helps!

MetadataException: Unable to load the specified metadata resource

Sometimes if we change the database connectionstring or copied database settings, when we compile we get this error

MetadataException: Unable to load the specified metadata resource

Simplest possible fix is in web.config, in connectionstring property you will see something like this..

connectionString=”metadata=res:///<modelname>.csdl|res:///<modelname>.ssdl|res://*/<modelname>.msl;

Simply change it to

connectionString=”metadata=res://*/;

Hope that helps!

Azure Web deployment task failed ERROR_FILE_IN_USE

Sometimes we are greeted with the following error when we are publishing websites/API service projects to Azure.

Web deployment task failed. (Web Deploy cannot modify the file ‘<project>’ on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)

Quick fix is find a pubxml file under properties folder. Under   <PropertyGroup> add the following line.

<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>

Hope that helps!