Main menu

SmartFeed by FeedBurner Subscribe to the site feed.


If you find the information here useful, then please consider a small donation, or linking to this site.

Recent Contributions

Calendar

October 2007
M T W T F S S
« Sep   Nov »
1234567
891011121314
15161718192021
22232425262728
293031  

Archive

Compiling C# code without access to Visual Studio

I’m not a developer and as such I don’t have a copy of Visual Studio but this evening I needed to compile somebody else’s C# code to produce a dynamic link library (DLL) and call it from a Windows PowerShell script. Somewhere back in my distant past I recall using Turbo Pascal, Borland C++, early versions of Visual Basic and even Modula-2 to make/link/compile executables but I’ve never used a modern compiled language (even on Linux I avoid rolling my own code and opt for RPM-based installations). So I downloaded and installed Visual C# 2005 Express Edition (plus service pack 1, plus hotfix to make it run on Windows Vista).

Sadly that didn’t get me anywhere - I’m totally confused in the Visual Studio IDE and anyway, the instructions I had told me to access the Visual Studio command prompt and run csc /t:library filename.cs.

It turns out that the Visual Studio Express Editions don’t include the Visual Studio command prompt but in any case, the C# compiler (csc.exe) is not part of Visual Studio but comes with the Microsoft.NET framework (on my system it is available at %systemroot%\Microsoft.NET\Framework\v2.0.50727\). Once I discovered the whereabouts of the compiler, compiling the code was a straightforward operation.

As for what I did with the DLL and PowerShell, I’ll save that for another post.

Comments

1

Pingback from markwilson.it [formerly known as Mark’s (we)Blog] » Controlling Virtual Server 2005 R2 using Windows PowerShell
Time: Thursday 11 October 2007, 23:22

[…] to impersonate the COM security on the required object (I initially had some trouble with this but everything was fine once I located the compiler). I placed the resulting VSWrapperForPSH.dll file in […]

2

Comment from tamberg
Time: Thursday 1 November 2007, 11:33

For a complete example see http://blogs.oberon.ch/tamberg/2007-10-17/compiling-csharp-without-visual-studio.html

3

Comment from Outsourcing
Time: Friday 5 December 2008, 12:40

I tell you thing for sure…even developers like me don’t know how to compile from the command line. Microsoft provides such a good IDE (Visual Studio) you never have to do it.

Anyway you should have used Visual C# Express by opening the .sln file and click Build. The .sln file is the project file.

4

Comment from Mark Wilson
Time: Friday 5 December 2008, 12:53

Thanks for that tip - I can see that the VS IDE is powerful… but it takes some time to learn - your advice is really appreciated :-)

Write a comment

Please note the rules for comments and the privacy policy and data protection notice. I'm sorry but, because not everyone sticks to the rules, I've had to implement some spam prevention measures - if you're experiencing difficulties leaving a comment, please let me know.





The following XHTML tags may be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>