I have a class inside a DLL (Database.dll) which has a static property:
public class Database
{
public static int[] ReleasedDatabaseVersions
{
get { return new int[] { 5, 6, 7, 8 }; }
}
}
I have created a standalone executable (ValidateInstall.exe) which needs to access ReleasedDatabaseVersions in the Database class.
However, I want ValidateInstall.exe to be entirely independent of Database.dll (i.e. I want to be able to run it on a PC without this DLL installed).
In C++ inlining would make this very easy. Is this possible in C#?
I don’t want to repeat this data in my executable as this would be a maintenance headache.
You could use ILMerge post-build to embed the assembly holding the
Databaseclass into your exe:The ILMerge page also links to an article by Jeffrey Richter, detailing how to achieve something similar without using ILMerge.