Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I compile C# programs with Visual Studio 2005? 1

Status
Not open for further replies.

CdnRebel

Programmer
Apr 5, 2003
39
0
0
CA
I am new to asp.net, C# and Visual Studio. I've updated an existing website, made all the coding changes and found out that I've been working with C# and that they need compiling. I do not have an IIS server attached to my computer. I do not have a registered version of Windows XP on my computer so I do not have access on my computer.

When I open the folder with my website on my desktop, I get a warning message about files being created in an older version and that they would be converted irreversibly. So when I go ahead with the conversion, my .csproj and .csproj.webinfo files disappear and my .sln file is written over. Should that be happening?

When I right click on the .cs file that I want compiled and click on Build Page, it asks if I want the website folder name.sln saved as UTF-8 Solution File (*.sln)and saved in the website folder. I don't know how to proceed and I don't understand the instructions given with Visual Studio 2005.
 
Although I don’t do a lot with websites I think you are being asked do you want the solution file saved in your website folder? If you click no then VS will probably save the solution file under my documents - > Visual Studio 2005 -> websites.... nothing to worry about!

Age is a consequence of experience
 
Hi,

I chose the option to create the websitefoldername.sln file in my website folder and unfortunately, I got error messages in that particular .cs file. However, I tried the Build Page on another .cs file and I got Build Succeeded. Does that mean that my .cs file has compiled and if that is the case, where do I look for the compiled object that I need to move to the actual website; so that, I can actually see the change? I really need hand holding on this.

Thanks!
 
CdnRebel -

I'm not sure if we are speaking the same language here, but you do not need to look for any compiled object. The .cs file (I'm taking a leap here and guessing) is a code-behind page. It is (mostly) worthless without a .aspx file of the same name.

If you cannot build the page, then there is something wrong with the .cs file you modified. Which is not really that surprising, considering you did not know you were working with C# ;-) So start there, and when the code in the .cs file is worked out you should be able to build and preview the page.

Then test it carefully before you refresh the .cs file on your website with the one you have updated.

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Thanks, Alex!

I was a mainframe programmer in another life. The .cs file is a code-behind page and it does come with a .aspx file with the same name. I've gotten rid of the errors and run the Build Page on all the .cs files that I changed. I am not sure though about what you mean by build and preview the page. I had the page in the main window while I ran the Build Page. Are you saying that the Build Page makes changes to the .cs files?

I don't have an IIS server attached to my computer because I don't have a registered version of Windows XP so I have been testing in a separate folder on the website and I have made the changes required to the .cs file in that test folder on the website, but it hasn't been picking up the changes. That's when I found out that I had been working with C# files and that they needed compiling.

In mainframe programming, when you compile, an object program is created and the machine works with the object program. So that's what I am not clear on. If the Build Page, compiles the .cs files, what new thing do I need to move into my web folder to see the changes? Is it just the same .cs file after it's been run through the build page?

Also, I believe that Visual Studio 2005 has converted my files from ASP.NET 1.1 to ASP.NET 2.0 (It created a conversion report). When I test on the website test folder, do I go by the conversion report and ensure that all the files that it changed should be moved to the website test folder and the live website, when all the bugs are out? I can't remember whether I had mentioned it, but I've been working with Visual Studio, just on a desk top website folder.

Thanks,
Mary
 
>>build and preview the page

hit Ctrl + F5. VS comes with a built in web service you can preview your pages with. When you "Build" the pages you will more than likely have the default PrecompiledWeb folder in the property pages (right click the solution in solution explorer and select "Property Pages". Go to MSBuild Options and check the path.

Or ot simplify it, go to Build-->Publish
Put a path in the box like C:\testPublish, tick "Allow this precompiled site to be updatable" and hit OK.

Go to C:\testPublish and you will see the aspx pages, web.config, Bin and other folders you have in the solution. In the BIN will be your DLL's from the compilation.

VS 2005 will of course alter your files when you upgade. You should have selected (it is by default) to create a backup prior to this. There will be a Backup Files folder in the projects folder containing all of these backups and or rate in the folder where your site is located

>>what new thing do I need to move into my web folder to see the changes?

Publish will remove all the files on the web server. You can publish to a local directory (as I mentioned) and move the DLL's over. I've received mixed results from doing that though. Works sometimes and other times breaks. Just be warned, BACKUP everything prior to updating a site. You can also command line compile the pages. Not sure you want to go there if you are where you are now.

Anything further should really be in forum855

[sub]____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Jeff,

I followed all your steps and moved the .dll files from the Bin folder to the test area in the website and the it still seems to be picking up the older versions. I'm going to download Service Pack 1 which supposedly has a conversion from 2003 to 2005 and see if that won't cut down on the error messages I am getting with the compiles before I go to further effort with cleaning up the error messages. I need to be done this in the next week or so because there are agents wanting to submit me for contracts in Cleveland.

Thanks,
Mary
 
The server that your publishing the files to is probably caching the DLL's so it will need a restart however if its a live server then this will obviously have to be checked as the last thing you want to do is restart IIS on a public server!

As for the conversion issues, I found my share and in the end I asked my employer to buy me a license for Visual Studio 2003 so I could run VS.2005 and VS.2003 side by side.

Service Pack 1 for Visual Studio 2005 is supposed to fix the conversion issues and make it much more seamless but I always found some issues afterwards like not being able to compile the code.

Your mileage may vary though, it all depends on how complex/clever your code behind is. Some people prefer to mix their code with some <script> tags in the aspx file and some in code behind; I am of the latter meaning I do all my work in code behind which is probably why Visual Studio 2005 has issues with my code as I have allot of stuff in there that is done 'my' way.

C# winforms and webforms are a world apart but share much the same ideas. In a nutshell you have your IIS Server, this loads in your precompiled DLL (the result of your compiled page) and then takes calls from your aspx page, processes them against the DLL and the results end up on your screen (or in the background)... well thats the simplified version ;)

As for publishing, depending on how you setup VS.NET 2005, out of the box it will always compile your site for you before publishing. But for some bizzare reason the MS dev's decided to change how sites are published in VS.NET 2005! In VS.NET 2003 you had some more options meaning you had more control over how your site was published.

I always take a backup of the site every now and then, even though VS.NET 2005 warns you about overwriting files it doesn't offer to back em up first.

Hope that helps,

Fz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top