Can I compile a single aspx.cs file into a DLL? - c#

I'm attempting to make a single small update to a website written in C#/ASP.NET.
All I'm trying to do is change the email address a form submits to, which is why I'm not seeking out a proper C#/ASP.NET developer.
I've done a little research, and it seems that the site itself is using dll files in the /bin folder to run the forms and things. The form is contact.aspx.f3293f9sd.dll, so I've edited the corresponding contact.aspx.cs file.
What do I do now?
Can I build this single CS file into a single DLL and upload it? I've scoured the menus and see no such option, and Google results seems to imply that you need to add entire projects and build entire projects at once.
Is that correct? What's the process here?

What you need to do is open the solution file. Solution files are files composed of projects. The contact.aspx.cs file is part of one of those projects. You need to make your change in the file, then recompile your solution. Then you can upload the DLL file it outputs to your production. Make sure you compile in Release mode.

Related

How to merge several Visual Studio projects in 1 Launcher project

So i made 6 different little applications each in its own Project.
And my idea is now to build some kind of Launcher with 6 buttons each of them launching their respectives applications.
I know how to /Add/Existing Projects/Select Project, but my worry is more upon managing to run those application on a Button_Click.
I'm thinking about copy/paste-ing my .cs files of each apps, and their resources.
Should I ? Shouldn't I ?
What would be the best thing to do ?
EDIT1
Well, as i said, my apps are very small, i mean like very very small. It's mostly about automating templates mails sendings and opening/closing reports.
All my apps are in a single form each and they only refer to .png or .txt to store datas or dress up fancy-ish reports with images.
Right now, I'm in the process of importing FormX.cs one by one, as NonStatic said, re-referencing the UI and renaming some functions. I did 2 so far, and i'm hitting a generic file path issue.
I'm not sure how ressources are working once the .exe is built. Are they "embed" whereever the ressources file is located ? (Resources folder, or ..\bin\debug) or should i be carefull with this and systematicly put tehm in some specific folder ?
Also, thanks for your point Zdravko Danev, i was about to just copy/paste everything. You made me think slower about this. But i'm kind of searching for a real merged solution, "fusioned solution" if i may say. I don't want buttons to just run .EXEs. :p
EDIT2
I managed to copy/paste all my forms, was kinda easy, though time consumming to check every references.
But it's done.
Most definitely do not copy the code!
It is relatively easy to create a simple launcher. Take a look at Process.Start:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
I think your question is not about merge projects but how to launch them in a uniformed application or launcher.
You could copy files together, rebuild user interface. In the user interface, calling methods in the copied files. Then you could public a single EXE file other than multiple files.
If your original projects generate dll files, you could build a new app which reference those dll files. Loading them when you need it and invoke methods from there.
If your original projects generate exe files, then #Zdravko's solution, using Process.Start() to launch those exe files with correct parameters.

How to make an updater for my WPF application? Installing only upgraded files

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.

How do you "Build" an exe that includes all the resource files like pics? Can exe be put on a web page?

I have students in high school who have created some programs using Visual Studio C#. They created some games and would like to now upload them to the web. I am pretty new to Visual Studio C#. I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on. It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place. How can I get a clean exe of their game? Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Microsoft wrote a guide on how to do exactly this. It's on their MSDN website, which is sort of like the developer back-bone for a lot of Microsoft software and documentation.
Old guide: Adding and Editing Resources (Visual C#)
Newer guide: How to: Add or Remove Resources
The gist is that the program needs to know where the files are, relative to the location of the compiled binary (in this case, an .EXE); There's several different ways to do this, depending on your level of expertise. I would suggest that you take a look at the guides above to start that journey.
there's a few ways of doing this. (Also, make sure you're creating a 'release' build when you compile).
You can include resources in your game by creating a resources file. This is something I usually do only on winforms applications etc.
If you have on-disk files you need to distribute those on-disk files along side your game. You could do this by zipping up your game.exe and the /files/images.img folder (or what ever your resources content folder is named).
If you're feeling adventurous you could create a 'deployment project' which is a project that allows you to create an installer file. This is a bit more work however you will have fine grained control over what files go where etc.
Good luck!
EXE files generally aren't self contained for video games with many resources, just add resources in an external folder and make sure the paths to the resources in their games are not absolute but relative in the local directory.
So for example:
get rid of paths like C:/Users/Bob/Desktop/Game/Images/player.png and replace with /Images/Player.png.
Also, an EXE generally doesn't run client side on webpages, it is possible but difficult. Things such as Flash are made for this sort of issue. I'd say make the webpage a place where they can download their games. Github has a nice way to do free websites called gh-pages. OFC, you could host one yourself but that would require a lot of setup work.
Like Monza said, you can zip up the files for download. Or, you could create an installer if you wanted to be really ambitious.
I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on.
That is correct, given that the other machine has the necessary .NET framework version installed AND any other resources like .dll files and config files are also present. When the application is ready for release, you can set the Build options in the project properties to Release, and then when you build all the files needed for distribution will be in the bin\Release folder.
It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place.
This may depend on how the application was written. If resources like pictures are embedded in the assembly then those files will not be needed to run on another machine. If the application is using hard coded paths for the image resources in the source code, then the application will likely break if the necessary files aren't present when the .exe is executed.
Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Yes - you could upload the .exe to a file server to make available for a download, but you would not be able to run it within a browser over the web. I would recommend zipping up the .exe and other files needed and hosting the .zip file on the web server for download; browsers may give a warning or block downloading an .exe .
Hope this explains it a little bit for you.

How to combine many CS files into a DLL file?

Basically what I'm trying to do is this:
1: Take an existing DLL file.
2: Edit some C# scripts inside. I'm doing this by using DotPeek to open in Visual Studio.
3: After editing the files, put them back into the original DLL file so the program works fine (modified by me).
So now I'm stuck on the last step, getting the files back into the DLL file so the program works. Any ideas? THANK YOU.
Extract all the source files from the dll, assemble a .csproj, and build it the same way as any other dll. That's the way I've done it. I'm sure there's some way to squirt individual types into the dll, but depending on the complexity of the dll, my method might be easiest (or completely impractical)

Website compilation process[AppCode DLLs]

We are working on a website project which contains around 1130 pages. After compilation, all the .aspx.cs files are converted into AppCode DLLs that has random names.
Whenever there are any changes in single .aspx.cs file[like a hotfix], we have to recompile and deploy the entire project on the application host.
We want to update only those files that have been changed and not the entire package.
One of a solution we are aware is that, converting Website to Web application; but we cannot implement that change at this stage of the project.
Is there any other way to find an efficient solution for this?
Yup. Talking in Visual Studio 2010:
While publishing the website, Select the option: 'Use Fixed naming and single page assemblies', Also select 'Allow this precompiled site to be updateable'.
After website is published. Go to the published folder. Open any aspx page (not the dll or .cs).. Note the dll name in page attribute under inherits attribute. Than using ftp or any other way to upload, copy or upload tht dll under bin to your website.
Also, you can create a doc or txt file to list all Dll names with respective paths to your file to easily know which dll to upload next time if there is any change.
Hope it helps.

Categories