Hace un momento que hiciste esta pregunta y ya has aceptado una respuesta, pero aún así intentaré ofrecerte una alternativa. Tuve el mismo problema y así es como lo resolví:
Agregué el dll como un origen a mi C# -Project y agregué este código a mi Main-Method (el que inicia su winform principal).
public static void Main(string[] args)
{
if (InitdeDEDll()) // Create dll if it's missing.
{
// Restart the application if the language-package was added
Application.Restart();
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new YOURMAINFORM());
}
private static bool InitdeDEDll() // Initialize the German de-DE DLL
{
try
{
// Language of my package. This will be the name of the subfolder.
string language = "de-DE";
return TryCreateFileFromRessource(language, @"NAMEOFYOURDLL.dll",
NAMESPACEOFYOURRESSOURCE.NAMEOFYOURDLLINRESSOURCEFILE);
}
catch (Exception)
{
return false;
}
}
private static bool TryCreateFileFromRessource(string subfolder, string fileName, byte[] buffer)
{
try
{
// path of the subfolder
string subfolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + (subfolder != "" ? @"\" : "") + subfolder;
// Create subfolder if it doesn't exist
if (!Directory.Exists(subfolder))
Directory.CreateDirectory(subfolderPath);
fileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\" + subfolder + (subfolder!=""[email protected]"\":"") + fileName;
if (!File.Exists(fileName)) // if the dll doesn't already exist, it has to be created
{
// Write dll
Stream stream = File.Create(fileName);
stream.Write(buffer, 0, buffer.GetLength(0));
stream.Close();
}
else
{
return false;
}
}
catch
{
return false;
}
return true;
}
}
Nota: Esto creará la carpeta y el lenguaje-DLL de nuevo si no se encuentra, por lo que no tiene que preocuparse más que copie esa carpeta y el archivo DLL con su archivo EXE . Si quieres que se desvanezca por completo, este no será el enfoque correcto, por supuesto.
http://stackoverflow.com/questions/1453755/how-to-embed-a-satellite-assembly-into-the-exe-file –
Probé ILMerge antes de publicar esto. Probé Assembly Linker pero no pude hacerlo funcionar. csc.exe dio algunos errores debido a las referencias y parece que el ensamblador de engarces hace que el ejecutable no use los recursos dll. – PythEch
No entiendo por qué MS obliga a reinventar la rueda ... – PythEch