visual studio

Could Not Load File or Assembly in Release Configuration

Problem:

    • Add a reference by browsing and selecting the corresponding dll. It's a dll not available in nuget package manager.

    • The project builds and executes fine in Debug Mode

    • The project fails to build or publish in Release Mode

Solution:

    • Go to Project Properties

    • Build. Select Release Configuration

    • Output section

    • Generate serialization assembly: Disable


Windows Service Cannot Uninstall Due To Installer Desynchronization

Use Fix problems that block programs from being installed or removed

or

sc delete "Service Name"

Migration Fails When Using Complex Types in AddOrUpdate

AddOrUpdate( p => new { p.Nombre, p.ProcesoID } cannot be used with EntityFramework < 6.2.0

When using scaffolding, visual studio automatically updates EntityFramework to 6.1.3.

You need to upgrade EntityFramework to at least 6.2.0 after scaffolding.

Windows Service Fails To Find Connection String

I copied+pasted a windows service and a windows service setup projects from one solution to another. Then I changed the connection strings in the app.config file and changed the project references. Then when I run the service and try to get data from the database I get the following error:

System.InvalidOperationException: No connection string named 'Context' could be found in the application config file.

Yet the connection string named 'Context' was present in the application config file.

The solution at the end was to create the windows service and a windows service setup projects from scratch.

When Debugging Windows Service Throws Errror System.InvalidOperationException: The model backing the 'Context' context has changed since the database was created. Consider using Code First Migrations to update the database

In this case the connection string points to a database in LocalDB and the database is up to date with migrations.

The error is misleading. The real error is that you need to set up an account with sufficient privileges for LocalDB access.

Even though the project installer has LocalSystem permissions, when debugging you need to set up an account with sufficient privileges.

Go to Services -> YourService -> double click -> LogIn -> Select "This account" -> enter credentials for the account with sufficient privileges