I'm very new to .NET world, I have a small console project (really small) that basically just reference an .DLL created in delphi (where most of the important code is), on my C# code I just have loops, thread sleep instructions and things like that.
My customers is using Microsoft Windows XP SP2, Microsoft XP SP3, Microsoft Windows Vista and Microsoft 7. I want to generate the .EXE in a way to run on all these environments. On my development environment with C# 2010 I have .NET framework 4.0, but I guess that some desktops at my customer has frameworks 3.5 and maybe older. Based on this situation, what is the best option to create the most portable EXE among new and old versions of .NET?
Detailed answer is very welcome since I'm beginner.
Since it may be my simple code, I'm pasting it here.
using System;
using System.Reflection;
using System.Threading;
using System.Web;
using System.Diagnostics;
using Redemption;
namespace test{
class Program
{
static void Main(string[] args)
{
RedemptionLoader.DllLocation64Bit = @"redemption64.dll";
RedemptionLoader.DllLocation32Bit = @"redemption.dll";
var ToEmailAddress = args[0];
var subject = args[1];
var pathFileAttach = args[2];
SendMail(ToEmailAddress, subject, pathFileAttach);
}
private static void SendMail(string ToMail,string subject,string filePath)
{
var session = new RDOSession();
try
{
session.Logon();
if (session.LoggedOn)
{
var Drafts = session.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts);
RDOMail msg = Drafts.Items.Add("IPM.Note");
var body = "Test Redemption.";
msg.To = ToMail;
msg.Recipients.ResolveAll();
msg.Subject = subject;
msg.Body = body;
msg.Attachments.Add(filePath);
msg.Save();
msg.Send();
System.Threading.Thread.Sleep(5000);
}
}
finally
{
session.Logoff();
session = null;
}
}
}
}
Develop and build against .net 2.0 as the Target Framework and it will be compatible with all versions going forward.
In the project menu you may select the version of .net you wish to use (use 2.0 as Chris said). Be careful, however, because sometimes by doing this, things may require some adjusting.
See here for a list of changes that may be important to you
It's also worth noting that under your project properties you may select what dependencies are required to run your application. It will check and allow the user to obtain these dependencies, such as a certain version of the framework, before allowing the install to progress.
Be aware that v1.0 and 1.1 of the .NET Framework are extremely difficult to ensure compatibility with. Although all version of the .NET Framework are technically backwards-compatible, 1.0/1.1 are first very basic (they don't even have generic types), and second there were certain language and implementation details that changed significantly when v2.0 was released that actually may not be compatible with a post-2.0 framework. It was highly recommended by Microsoft that all .NET 1.1. programs be recompiled to target 2.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With