.

[resolved] npm certificate issues

Receiving the following error:

npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN

Upgrade your version of npm

npm install npm -g --ca=""

– OR –

Tell your current version of npm to use known registrars

<code>npm config set ca ""</code>

– OR –

Disable Strict-SSL 

npm config set strict-ssl false

 

– OR –

Switch from https to http 

npm config set registry="http://registry.npmjs.org/"

 

 

Resolved: Could not load file or assembly ‘Newtonsoft.Json’ or one of its dependencies.

Getting the following error:

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.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Run this in the Tools -> Library Package Manager -> Package Manager Console

Update-Package –reinstall Newtonsoft.Json

Solved – Cannot attach the file ‘xxx.mdf’ as database ‘yyy’.

Getting this error:

Cannot attach the file ‘xxx.mdf’ as database ‘yyy’.

This can happen when you delete an EF database manually and it remains registered.

Solution:

Simply stop and delete your localdb – by running the following 2 commands in package manager (Tools – > Library Package Manager -> Package Manager Console)

sqllocaldb.exe stop v11.0
sqllocaldb.exe delete v11.0

and recreate the database if necessery (code-first):

Update-Database

Solved – The type or namespace IHttpActionResult not found (Web API 2 error)

Trying to use Web API 2 but getting the following error:
error CS0246: The type or namespace name ‘IHttpActionResult’ could not be found (are you missing a using directive or an assembly reference?)

Solution:

Tools – > Library Package Manager -> Package Manager Console, then type:

Install-Package Microsoft.AspNet.WebApi -Version 5.0.0

sometimes you must try:

update-Package Microsoft.AspNet.WebApi –reinstall

 

AllowGet JsonRequestBehavior

Getting the following error:
This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

Try to add “JsonRequestBehavior.AllowGet” to your return statement.

public JsonResult GetJsonData()
{
    MetricValue m = new MetricValue();
    m.Error = "234";
    m.SnapshotId = 4;
    return Json(m, JsonRequestBehavior.AllowGet);
}

now my output is:

{"MetricId":0,"SnapshotId":4,"Error":"234","Value":null}

 

The constructor to deserialize an object of type ??? was not found

See solution to my problem below – I got the following stack trace (error) while binary deserializing a class:

The constructor to deserialize an object of type ‘Microsoft.Skype.Horizon.Business.DataCollection.Exceptions.DataCollectionException’ was not found.

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.Runtime.Serialization.SerializationException: The constructor to deserialize an object of type ‘Microsoft.Skype.Horizon.Business.DataCollection.Exceptions.DataCollectionException’ was not found.

Source Error:
return formatter.Deserialize(stream);

My code was:

[Serializable]
public class DataCollectionException : Exception
{
}
Solution:  simply add the following constructor

public DataCollectionException(SerializationInfo info, StreamingContext context)
        : base(info, context) { }

so that the code now looks like this:

[Serializable]
public class DataCollectionException : Exception
{
    public DataCollectionException(SerializationInfo info, StreamingContext context)
        : base(info, context)
    {
    }
}

[resolved] A potentially dangerous Request.Form value was detected from the client

When posting to a MVC controller, I get the following error:
A potentially dangerous Request.Form value was detected from the client

To get around this, disable validation by adding this attribute to the controller method you’re posting to:
[ValidateInput(false)]

Issues installing Microsoft Windows SDK for Windows 7 and .NET Framework 4

I ran into the following problem when trying to install FxCop.

Problem:
Error while installing “Microsoft Windows SDK for Windows 7 and .NET Framework 4″:

Error Message:

11/14/13 12:32:25 DDSet_Status: LANGID: 1033
11/14/13 12:32:25 DDSet_Entry: ImmediateDispatch: DDSE_CA_Uninstall_InstallExecuteSequenceStarts entry
11/14/13 12:32:25 DDSet_Error: Patch Hooks: Missing required property ‘ProductFamily’: Setup cannot continue.
11/14/13 12:32:25 DDSet_Warning: Setup failed while calling ‘getDLLName’. System error: Cannot create a file when that file already exists.
11/14/13 12:32:25 DDSet_CARetVal: 0
11/14/13 12:32:25 DDSet_Exit: ImmediateDispatch: DDSE_CA_Uninstall_InstallExecuteSequenceStarts exit

Solution:
I uninstalled of all the Microsoft Visual C++ 2010 Redistributables (both x86 and x64) and rerun Setup.

Solved: One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

Getting the Error: One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

Solution:
Add Reference -> .NET -> add Microsoft.CSharp.

[solved] The project type is not supported by this installation

In my case (after upgrading Asp.Net MVC3 to Asp.Net MVC4 application)
The following ProjectTypeGuids solved the issue:

<ProjectTypeGuids>
{E3E379DF-F4C6-4180-9B81-6769533ABE47};
{349c5851-65df-11da-9384-00065b846f21};
{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>

I believe they mean the followin (in the same order as above):

Asp.Net MVC 4
Web Application
C# project