The .NET MVC model has to have a parameterless constructor

When you create a class to be used as the model in a .NET MVC application, the class has to have a parameterless constructor. It is called during the POST when the user clicks the submit button of the form. If the class does not have a parameterless constructor, we will get the following generic error message. None of the breakpoints can help you to find the cause, and there is no entry in the event log.

The website cannot display the page
HTTP 500

Most likely causes:
•The website is under maintenance.
•The website has a programming error.

What you can try:
Refresh the page.
Go back to the previous page.
More information

An error occurred while signing

When you deploy and application in Microsoft Visual Studio with ClickOnce, you need to sign the installer with a key.

To sign the project Visual Studio needs to use the signtool. If the ClickOnce feature is not enabled in Visual studio, it displays the following error message:

An error occurred while signing: SignTool.exe was not found at path C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe

To install the ClickOnce feature and the signtool

On Windows 7

  • In Windows Control panel select Programs and Features,
  • Right click Visual Studio 2015 and select Modify,
  • In the feature list select ClickOnce tools.

On Windows 10

  • In Windows Control Panel select System,
  • On the left side select Apps & features,
  • In the app list click Microsoft Visual Studio 2015,
  • Click the Modify button,
  • In the Visual Studio setup click the Modify button again,
  • In the feature list select ClickOnce Publishing Tools.



When you have been able to successfully sign your Click Once applications in the past and suddenly you get the error message

An error occurred while signing: Failed to sign bin\Debug\app.publish\….exe. SignTool Error: No certificates were found that met all the given criteria.

it is possible that the certificate you used to sign your app has expired. To check the validity of the certificate

  1. In Visual Studio open the project’s properties page,
  2. On the Signing tab check the expiration date of the certificate.

Create a new certificate

To create a new certificate

  1. On the Signing tab of the project properties page click the Create Test Certificate button,
  2. Enter a password for the new certificate.
  3. Click the down arrow next to the key file name and select the new key file in the dropdown list.
  4. Save the project file and build your application.




No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer

When you move your Visual Studio solution to another workstation you may encounter the following error message:

System.Data.Entity.Core.MappingException was unhandled by user code
Message=Schema specified is not valid. Errors:
: error 2062: No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer …


In this case it may help if you re-import the database objects into the .edmx file.

To import all objects again:

  • Open the .edmx file,
  • Press the Ctrl-A keys to select all tables in the diagram,
  • Press the delete key on the keyboard to delete all tables,
  • Right click the white area and select Model Browser,
  • In the Model Browser expand the {model name}.Store, and the Stored Procedures / Functions element
  • Delete all functions and stored procedures
  • In the {model name} element (the element above the {model name}.Store) expand the Function Imports element
  • Delete all function imports
  • Save the .edmx file
  • Right click the white area of the .edmx file and select Update Model from Database
  • Select all necessary tables, stored procedures, and functions and import them.

If you re-import the tables, but do not delete the stored procedures, functions, and function imports you may get the following error message:

Message=The function import ‘Tobacco_WebEntities.spGetAgeGroupId’ cannot be executed because it is not mapped to a store function.


Save the key file password in Visual Studio

When you have already set up the project signing of the C# application for ClickOnce deployment, and move the solution to another workstation you may get the following error message when you build the solution:

Severity Code Description Project File Line Suppression State
Error Cannot import the following key file: .....pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_....

We get this message, because the new workstation does not know the key file password. To solve this problem, we have to save the key file password on the new workstation.

To make your solution work again

  • Open the Visual Studio project properties window,
  • On the Signing tab click the pull down that shows the name of the key file.
  • Select Browse,
  • Select the key file,
  • Enter the password in the Password text box.

Include PBD files in ClickOnce deployment to show the line numbers in the Stack Trace

If there is an error in an application, the line numbers are only included in the Stack Trace when the PBD files are also in the application directory.

To include the PBD files in an application that was distributed with ClickOnce deployment you need to:

  • Right click the main project and select Properties
  • On the Build tab
    • Uncheck Optimize Code to make sure the line numbers in the Stack Trace match the source code
    • Click the Advanced… button at the bottom of the window
    • Set Debug info to full
      VS PBD 01

  • On the Publish tab click the Application Files… button
    • On the Application Files window select the Show all files check box in the lower right corner
    • Change the Publish Status of the PBD files from Exclude (Auto) to Include
      VS PBD 02
    • Click OK to save the changes

Visual Studio 2015 is very slow on Windows 10

When I have upgraded Windows 7 my computer to Windows 10 I have also installed Visual Studio 2015 professional. From the first moment Visual Studio 2015 was very slow. My computer was freezing all the time.

I have read many articles about the slowness of Visual Studio 2015, but I cold not find anything that helped, so I have decided to switch back to Windows 7. Unfortunately after the downgrade process my computer did not boot anymore. Finally I had to reinstall Windows 7 and all my applications. Luckily all my files were on the hard drive, so I did not lose anything.

Since that, I have found the following recommendation at

  • Uncheck [Tools->Options->General->Automatically adjust visual experience based on client performance]
  • Uncheck [Use graphics acceleration if available]
  • You can leave [Enable rich client visual experience] checked

Sooner or later I will have to bite the bullet and install Windows 10 again, hopefully by that time Microsoft corrects this very serious problem, or I will try these steps to make it work.


NUnit in Visual Studio 2015

To use NUnit in Visual Studio 2015

Create a unit test project and download NUnit from NuGet

  • Start Visual Studio 2015 and open or create a solution
  • In your solution create a new class library for your unit tests
  • Right click the unit test project and select Manage NuGet Packages
  • Type NUnit into the search field
  • Install
    • NUnit
    • NUnit Test Adapter
    • NUnit Runners

Create unit tests

Run the unit tests

Windows web service authentication in IIS Express

When you develop a SOAP web service in Visual Studio 2013 the IDE uses IIS Express for testing. To set up Windows authentication in IIS Express follow the steps below:

Create a Local Security Group on your computer

  • Right click Computer and select Manage
  • On the left side expand Local Users and Groups
  • Right click the Groups folder and select New Group
  • Create a group with the name WebserviceUsers for the users of the web service
  • Right click the Users folder and select New User
  • Create a user and add it to the WebserviceUsers security group

Add the following lines to the  <system.web> section of the Web.config file of your web service application

<authentication mode=”Windows”/>
<allow roles=”WebserviceUsers”/>
<deny users=”*”/>

Set up IIS Express for Windows authentication

  • Select the web service project in the Solution Explorer
  • In the View menu select Properties Window
  • Disable Anonymous Authentication and enable Windows Authentication
    Visual Studio IIS Express Windows Authentication Properties Window


In the caller application call the web service with user name and password

  • Add the following lines to your class to supply the credentials
private Webservice.Service _Webservice = new Service();

// Constructor
public Business() {
    string webserviceUrl = "Webservice_Url";
    string webserviceUserName = "Webservice_UserName";
    string webservicePassword = "Webservice_Password";
    _Webservice.Url = webserviceUrl;
    ICredentials credentials = new NetworkCredential(webserviceUserName, webservicePassword);
    _Webservice.Credentials = credentials;

How to add tooltip to a Windows Form

In Windows Form applications the tooltip functionality is not built into the controls as in HTML objects.

To add tooltip to your controls on Windows Forms

  • Open the Windows Form in the designer
  • Drag the ToolTip control from the Common Controls section of the Toolbox to the form. The ToolTip control will be placed at the bottom margin of the design surface outside of the visible area of the form.
  • A new item appears in the Misc section of the property list of the form controls (buttons, textboxes, etc): ToolTip on toolTip1
  • Enter the text there you want the users to see when they hover above the control.