Yes you can:
- Open the project properties, go to the resources tab and select "Add Resource > Add existing file" ("Ressource hinzufügen > Vorhandene Datei hinzufügen"). Select the DLL. It should appear somewhere in the resources, either under "files" or under "other".
- Copy it from the resources to file as follows
In your code, check whether it is present when the application starts. The following assumes you're using WinForms. If not, the code can also be added to the WPF App
class. There's a method you can override that's called when the WPF application starts.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string dllPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filenameofdll.dll");
if (!File.Exists(dllPath))
{
byte[] fileBytes = Properties.Resources.<resourcename>;
File.WriteAllBytes(dllPath, fileBytes);
}
Application.Run(new Form1());
}
<resourcename>
in the above code will be the name of your resource. It should be auto-completed by IntelliSense.
This should work provided that the DLL is only used after that above code executes. The DLL should only be loaded when the first instance of a class from the DLL is created, so you should be fine.
DISCLAIMER
I do not know whether this has licensing implications! Please make sure that you're not doing anything illegal. Also: The above will only work if the application has write permissions to the folder.