I am new to C#, and I have a project which I have a built as a class library to check for updates before the app starts.
For the program to run this dll file should be in the same directory where the main app is, I want to change the directory of this dll file to be in a sub folder.
I have tried to change app.config file, but it started to cause runtime errors.
Is this possible?
If you import Updater Project into your main project, MsBuild compiles both of them together. And you won't need to deal with such complexities.
Honestly, ı couldn't understand what you tried to do. But above approach would solve your issue.
Related
I have a 32 bit application that uses a DLL built by someone else, lets call it xyz.dll. This DLL has dependencies on few other old DLLs. All dlls are saved in the same folder where my app is located. My app compiles fine but in run time, it throws an error "Could not load file or assembly "xyz.dll" or one of its dependencies. is not a valid Win32 application"
I have 2 workarounds that seems to solve this problem. In first one I moved the DLLs to a separated folder and created a batch file to run the app. The batch file first add the dlls' path to the environment, then call the app. Interestingly if I leave the dlls in the same folder with the app and just add this to the path, it wouldn't work.
The second way also moved dlls to a folder and add this path to user environment variable and run the exe directly. Either one of these solutions requires extra steps which is not ideal for app deployment. I am wondering if there is a better way?
When your dll is in the same folder as the application, it is that dll that the application attempts to load, and this fails, as you said.
When you move the dll to another folder and add the pathname of that folder to the PATH environment variable, the application works. In this case, the application is not attempting to load the dll that you have moved to another folder. If this were the case, it would fail. It must be loading another version of the dll that is in one of the folder paths that are in your PATH environment variable.
Simply use Windows search to find all copies of your dll file on your computer. You will be able to determine where that other dll is.
I finished my app and now I want to create a update system. I have the installer so I can install the application in other machines, it was made with InnoSetup (I don't know if it is the best way, but it worked). I know the basics, I have to compare the current version with a string stored in a in a web server, if it is greater, download the files. Now, what files? Because the InnoSetup gives me these files:
Where are the .xaml (design) files? And the .cs files? Are they compressed in the .exe? For example If I add a few lines to a class, I want to download this class, no the full installer again. Because the final size of my application is 30Mb, if I change some things of a class, I do not want the user to have to download the 30Mb again
In the most basic of terms, when you compile your program the compiler turns your cs and xaml files into machine readable code and puts it all into an exe file.
Yes, if you add a few lines to a class and recompile it, it will rebuild your exe (assuming the class is part of it, and not an external library).
You still have dependency dll files that you need to include, and any other external content that you've included. But once you have all the external files installed, you wouldn't theoretically need to download them again on an update. Only the files that you've updated, ie the exe.
I wish to ask you how to create a workable .exe from my form application project.
Project name is lottery and when I started the Build solution , program say me, that build is successed, after that I'm going to
C:\Users\mdinev\Desktop\LottaryPresentation\Lottary.Business\bin\Debug
This is exactly my path, but here is also my .dll and config file.
I'm working with VS2015 and my target is to give this .exe to other department team to started a lottery program.
Is it possible to create this exe file, may be they have to insall other version ot .net framework, but other team only wish for me to present them an .exe file.
Thanks in advance for help.
Just change the Output type to Windows Application and you will get your .exe file.
Edit:
You can do that by right-click your project, go to Properties/Application and change the Output type from Class Library to Windows Application
In resume, we want to use the CefSharp dll to embed a browser in our .NET app.
We don't want to add size to our setup since the dll size is quite large.
Here is what i try to do :
I reference the DLL in my project as Copy local to false which when
compiling will not link the DLL in the files.
Before using the cefsharp class in my code i download the DLL plus all the file needed and extract it where the app .exe is located
This is where i hit a wall, if i try to use the cefsharp class after everything is done at the good place the cefsharp will not work
which is normal because the dll have not been loaded (unless an app restart).
Is there a way
to dynamically link my already referenced dll in memory, so i don't
have to restart my application?
Thanks !
I ended up restarting my app...
broken to bare-bones scene:
I have a program in c# that calls a .exe inside cmd(using process.start), passing some required arguments.
What i'm trying to do: Include the exe into the project so that i don't have to call cmd.
Any idea?
If you just want to include so you don't have to ship two files then just include it into the project as "embedded resource" (see project item options) and then you can call ResourceManager.GetStream and write it to file and call Process.Start.
If you want integrate the functions of that exe so that the exe is not needed anymore (no Process.Start) then you need the source code...
EDIT:
the "write to file" is not necessary if the exe is .NET - then you can directly load it from the resource stream as Assembly/AppDomin and execute it.
You can add an exe as an embedded resource (just right click on a folder in the Solution explorer, Add Existing Item, then get properties on it and set it to be Embedded Resource). However, you may not be able to easily execute it in place - you'll need to save it to disk and then execute it (which doesn't solve your stated problem of having to ShellExecute the .exe file, but does solve the problem of having to ship more than one file to the end user).
If you have the source code, then you'll be able to repackage the exe as a dll, or integrate it directly into your program code.
If the exe is a .NET assembly, you could use ILMerge to merge the exe into your main assembly. You can then invoke the code in the exe directly.