Code behind (.cs file) vs compiled .Dll file - c#

I have a client that I created a custom app for that integrates with BigCommerce. The question I have is since I do not want the client to have access to the .CS files for codebehind, do I have to deploy those as well, or can I just upload the .DLL file? If I can, what needs to be done to accomplish this.

you just need to "publish" the project and it will already move just the files it needs to run.
It is basically dll, .aspx, .css, .js etc ... and NO .cs files

If securing your code is your concern, then the compilation to a DLL will not really buy you too much security, as non-obfuscated code will be easily decompiled by .NET Reflector or ILSpy.
To get some level of code security from prying eyes wanting to steal your logic, then you need to use an code obfuscation tool like SmartAssembly

Publish it or make a installer is the best way. :)

Related

How to decompile ASP.NET web application [duplicate]

we have an application in production and the code is in Pre-Compiled form. The developer who developed that application left the company and we don't have any backup of source code. the only access we have is Pre Compiled code in the server. We need to fix the issues in the application now.
Is there any way to Decompile (extract to actual source code) the PreCompiled code ?
Open the DLLs in the .NET Reflector.
To update #xOn's answer:
Due to a recent source control disaster I had to recover my project from the DLLs. So sadly I'm knowledgable on the procedure:
Get .Net Reflector from here: http://www.red-gate.com/products/dotnet-development/reflector/
You do not seem to need FileDisassembler.
Either load your bins in Reflector or double click them.
Mind that the .Net framework might have not maintained your original project file structure. So if some of your ASPX pages shared the same basic class name in different .cs files (I.E. Inherits tag is the same, but CodeFile tag differs), you would not be able to simply "export source code".
Don't go blindly exporting source files. It won't work.
There will still be some work to be done before being able to just fire up the old build button. For example - DLLs can refer to property's getter/setters directly. You will have to fix that.
Good luck.
Start with:
http://www.red-gate.com/products/dotnet-development/reflector/
...plus:
http://www.denisbauer.com/NETTools/FileDisassembler.aspx
You'll have to recompile the latter to link it against v6.5 of reflector (the latest, as of this post.) It is a good add-on if you want to avoid having to copy and paste ever single class into files by hand. It will dump an entirely assembly as .cs files. I think it may even generate a csproj.
Both tools are free.
I had the similar issue and used Reflector to Decompile it. I got the source code, then changed the bit I wanted, and rebuild it. Then I copied that dll again to Production site. It started to reflect my changes. It was very easy and not at all difficult, maybe because Precompiled site had dlls for every page, and was updatable , so had only code-behind file in dll.
For reference: http://www.reflector.net/
When u install .net reflecter.its import in visual studio.
then you saw the .net reflector tools on menu bar.
Click on .net reflector >>Choose Asseblies (Dll file) to debug.
I found that dll can be just Read using the .NET Reflector tool but can't extract the Source Code. And also once the webforms are precompiled, we can't even get back the code behind files. All we can do is to debug and analyze the Code.

Linking Modules into Small Footprint Assemby

According to http://blogs.msdn.com/b/junfeng/archive/2005/02/12/371683.aspx I should be able to create a single .exe file build from some source code and a .netmodule file. However, after looking at http://msdn.microsoft.com/en-us/library/92b5ab4h.aspx and http://msdn.microsoft.com/en-us/library/k669k83h.aspx I cannot seem to make this happen. Whenever I run my .exe it is looking for the .netmodule externally.
Does anyone know of any example showing which options I have to pass to csc to make this do what I want?
For example I have, common.netmodule and program.cs, and I want a single file program.exe that has common.netmodule in the assembly.
After rethinking things, I decided to solve the problem at the source code level. Instead of compiling a common.netmodule file, I just have Maven copy my common.cs file into the project specific directories, and then compile. It works, it's simple, and I cannot believe I wasted so much time trying to figure out the abstruse details of .Net assemblies.

recover lost C# pages

I had a problem I lost all my source(CS) of web site pages but I had only published pages on server ,so please if there is any way to recover theses published pages to orignal pages with code,bin folder
You need to decompile the C#. It is an advanced user scenario, but it can be done... sort of.
How do I decompile a .NET EXE into readable C# source code?
try to use reflector. it help you to restore all your code
Use your latest backup copy, or roll back to the previous version of SVN you are working on.
http://www.red-gate.com/products/dotnet-development/reflector/ is a good piece of software for recovering source from a compiled program.
If your project was a website, you should be able to ftp each file from the server 1 for 1. If your file was a web application project, you're hosed. The code files are compiled into a binary, and if you lost the source code it's gone.
http://www.red-gate.com/products/dotnet-development/reflector/ Can decompile .NET assemblies into source code - however it won't be the code you wrote as alot of it will have been changed by the compiler (IE your comments will have gone bye bye)
You can then rebuild your Project in your IDE of choice and you are done.
If the assemblies haven't been obfuscated, you can use reflector to recover your code from the assemblies.

Dynamic ASP.NET application compilation

My web application (ASP.NET v3.5 / C#) dynamically creates other asp.net applications (creates aspx, aspx.cs, classes, web.config, project.csproj file etc.).
The thing is even after I configure the 'new' application folder as APPLICATION in the IIS, When I try to browse it, I get the following parser error: Could not load type 'Template48.Template48' (where Template48 is my application).
When I manually browse to the new application folder, and re-build it, all works perfect.
How can I re-compile this WHOLE application, but in it's folder ?
Thanks in advance,
Gal.
A web application needs to be compiled before it works; this is different from a web site.
Just providing the sources isn't enough; in fact, ASP.NET doesn't need the sources (aspx.cs) to run the application, just the .aspx, web.config, and .dll files ("assemblies" in .NET lingo). It is even considered good practice to remove the sources from the production system to avoid accidentally leaking the sources and giving attackers information about the site's inner workings.
To make this work, you need to somehow invoke the command-line C# compiler to build the project on the fly; this will generate the needed .dll files.
A different, but much harder, route would be to use .NETs ability to emit IL at runtime; using this facility, you could produce assemblies directly without going through the compiler. This is pretty difficult though, and you need thorough understanding of the IL to pull this off.

ASP.net/C#: How compile classes in App_Code so that can be run from command line for unit testing?

I have several class files in App_Code in an ASP.net website running in Microsoft Visual Studio 2005 Professional.
In liu of using a full unit test suite I just want to somehow compile those project-wide classses into an .EXE so that I can nightly run unit tests on them.
I do know how to create a separate C# library project consisting of those files and how to include them into my website--but that is not desirable--I don't want to give up the ability to make on-the-fly code changes of those library classes when running the website in the debugger. As far as I know .Net debugger isn't powerful enough to modify code in included libraries with instant auto re-compilation on page re-load.
So, I want my cake and eat it, too:
Command-line unit testing of website class files in App_Code directory
Being able to modify those class files w/o stopping/re-starting the web debugger.
Is it possible to have both?
You should put the code in an altogether separate class library/assembly, then reference it from your web project and the command-line utility. As far as I know, it makes no difference where you modify your code, when stopped in the debugger. Never had problems myself.
Hope that helps.
Your project is under source control, right? Right? In that case, you can use your source control system to include a link to your asp.net project's app_code folder as part of a separate unit testing project. The exact linking mechanism varies by source control platform, but done right it means there's exactly one instance of your App_Code folder in source control that's visible from two different projects. This way, everything stays up to date.
This has the advantage of allowing you to keep easy, uncompiled code right there just like you always have, but still making the code available for testing.

Categories