I want to force the compiled program to use the dll from the %temp% folder.
However, if I do like that
compars.EmbeddedResources.Add(Path.GetTempPath() + "\\Newtonsoft.Json.dll");
compars.ReferencedAssemblies.Add(Path.GetTempPath() + "\\Newtonsoft.Json.dll");
The program crashes.
I have also added using Newtonsoft.Json.dll but I still need to have the Newtonsoft.Json.dll in the same folder as my program, if so, the program isn't crashing, otherwise it crashes even if Newtonsoft.Json.dll is in the %temp% folder. So in general, I want to run the program successfully without having the dll in the same folder, and force it to use the dll from the %temp% or something like that.
You can embed other
dllsinto your program easier. Please refer to the following link:stackoverflow.com/questions
You can also use
ILMergeto do it automatically.You can also surround your code with
try-catchto get more detailed information. I guess your dll's version is not equal or some similar issues.