Drag and drop a DLL to the GAC (“assembly”) in windows server 2008 .net 4.0

In .net 4.0 Microsoft removed the ability to add DLLs to the Assembly simply by dragging and dropping. Instead you need to use gacutil.exe, or create an installer to do it. Microsoft actually doesn’t recommend using gacutil, but I went that route anyway. To use gacutil on a development machine go to: Start -> programs … Read more

How to find the main() entry point in a VB.Net winforms app?

In VB you’ll need to create your sub main by hand as it were so what I generally do is create a new Module named Program. Within that as a very basic setup you’ll need to add the following code. Public Sub Main() Application.EnableVisualStyles() Application.SetCompatibleTextRenderingDefault(False) Application.Run(New Form1) End Sub Once you’ve done that go to … Read more

T4 without Visual Studio?

I wrote a cleanly reverse-engineered implementation of a T4 engine for the MonoDevelop IDE. It’s open-source, licensed under the permissive MIT/X11 license, so you are free to embed the engine in your app or redistribute it. There’s also an implementation of the TextTransform.exe command-line tool available as a dotnet global tool, and some APIs in … Read more

How do I set CultureInfo.CurrentCulture from an App.Config file?

I don’t know a built-in way to set it from App.config, but you could just define a key in your App.config like this <configuration> <appSettings> <add key=”DefaultCulture” value=”pt-BR” /> </appSettings> </configuration> and in your application read that value and set the culture CultureInfo culture = new CultureInfo(ConfigurationManager.AppSettings[“DefaultCulture”]); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; Also, as … Read more

How can I configure Entity Framework to automatically trim values retrieved for specific columns mapped to char(N) fields?

Rowan Miller (program manager for Entity Framework at Microsoft) recently posted a good solution to this which uses Interceptors. Admittedly this is only valid in EF 6.1+. His post is about trailing strings in joins, but basically, the solution as applied neatly removes trailing strings from all of the string properties in your models, automatically, … Read more