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

ConcurrentDictionary Pitfall – Are delegates factories from GetOrAdd and AddOrUpdate synchronized?

Yes, you are right, the user delegates are not synchronized by ConcurrentDictionary. If you need those synchronized it is your responsibility. The MSDN itself says: Also, although all methods of ConcurrentDictionary are thread-safe, not all methods are atomic, specifically GetOrAdd and AddOrUpdate. The user delegate that is passed to these methods is invoked outside of … Read more

How to Specify Primary Key Name in EF-Code-First

If you want to specify the column name and override the property name, you can try the following: Using Annotations public class Job { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Column(“CustomIdName”)] public Guid uuid { get; set; } public int active { get; set; } } Using Code First protected override void OnModelCreating(DbModelBuilder mb) { base.OnModelCreating(mb); mb.Entity<Job>() .HasKey(i => … 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 to configure SMTP settings in web.config

By setting the values <mailSettings> section of the in the web.config you can just new up an SmtpClient and the client will use those settings. https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.-ctor?view=net-6.0#system-net-mail-smtpclient-ctor Web.Config file: <configuration> <system.net> <mailSettings> <smtp from=”yourmail@gmail.com”> <network host=”smtp.gmail.com” port=”587″ userName=”yourmail@gmail.com” password=”yourpassword” enableSsl=”true”/> </smtp> </mailSettings> </system.net> </configuration> C#: SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(msgMail); However, if authentication is needed, … Read more