Visual studio outputs this message during build. when updating nuget packages, in a log message more or less like this: Resolution: Create a new registry DWORD value called LoaderOptimization and give it the value 1 within the key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework”. see also: https://stackoverflow.com/questions/42240956/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances see also: https://learn.microsoft.com/en-us/archive/msdn-technet-forums/5db05238-3c12-4e7e-af95-ca56545f0721 see also: https://blog.bugrapostaci.com/2017/02/08/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401/
Category: C#
Performance counter browser
A simple windows tool to browse performance counters on your local system In the first column, the list of categories is shown Upon selection, the second column will show the list of instance After which the third column will show the actual list of performance counters If you select an actual counter, the bottom right will show you a sample from the counter with a 1 second interval. Source and releases can be downloaded from github
EF Framework core for ling2sql users
Linq2Sql had a few extremely practical tools such as sqlmetal enabling you to generate code form an existing database with a single command, replace a single file and be done with it. EF Core seems to align with the trends lately to make everything more cumbersome, but you can stil use a workflow much like […]
Using backgroundworkers with progress reporting and cancelation
With the release of VS11 around the corner and the new async features in there everyone will have a wide toolset for writing non blocking responsive applications. If you have not yet played with the beta versions or regular threads (see for example Threads and the threadpool then the backgroundworker is the most basic component […]
Coloring individual cells or rows in a DX Gridcontrol based on a cell value
Coloring individual cells This sample hooks into the RowCellStyle event of the Gridview, and evaluates the value of the cell. Depending on the outcome, a background color is assigned to the cell. private void gridViewQueue_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { var oView = (GridView)sender; if (e.Column.FieldName == “task_stamp”) { Color oBgcolor; var dtValue = DateTime.Parse(oView.GetRowCellValue(e.RowHandle, “task_stamp”).ToString()); […]
Distinct, join and outer Join with linq to sql
While stored procedures will beat linq most of the time if you want top notch performance, there is a distinct advantage to LINQ when it comes to readability of your code, and keeping things a little more central within the application. These samples make use of the NorthWind database, and a dbml file called NorthWindContext.dbml […]
Importing data from an Excel sheet
C# Example using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.Linq; using System.Text; namespace Excel2Table { public class ExcelReader { /// <summary> /// Reads an excel file with OLEDB, and returns a datatable object from the content. The sheet to be imported /// needs to be named “Import” in the excel file. /// </summary> […]
Threads and the Threadpool
This small demonstration code snippet will show you how to: Create threads to run code in the background of your application Demonstrate how to pass one or more parameters to a background thread Demonstrate how to wait for all background activity to finish before exiting the main program. using System; using System.Collections.Generic; using System.Threading; using […]
Using LINQ with MySQL
This code demonstrates access to OSCOMMERCE database objects which are hosted on a mysql server, through the enitity framework and LINQ. Additionaly, the connectionstring is overriden at runtime to seperate developent and production environments. Install the MySql connector for visual studio Add a ADO.NET Entity data object to the solution Use the Wizard to create […]
Resursively listing a directory tree using a stack object
The class offered below shows an implementation of an efficient way to scan large filesystem trees and returning the content. By not using recursion but controlling the worklist with a stack element a large part of the load on the GC is reduced. Using recursion the collection of created objects by the recusrive calls can’t […]