.NETGURU
Compiling a custom control
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvs' list.


Rich Evans
-- Moved from [aspngfreeforall] to [aspngvs] by Tim Musschoot <Click here to reveal e-mail address> --

Hi everybody. I'm new to ASP. I'm trying to setup a custom control and am
going through the tutorials in the SDK "Developing a Simple ASP.NET Server
Control [Visual Basic]". According to the instructions:

6. Save, compile, and deploy the control by executing the following steps.

Create a subdirectory named /bin in your application's root directory.

Compile the source file into an assembly (.dll) and save the assembly in
your application's /bin subdirectory.

For example, if your source code is in C# and you save it to a file named
FirstControl.cs, you can execute the following command from the directory
containing the source file.

csc /t[arget]:library /out:[path to bin]bin\CustomControls.dll
/r[eference]:System.Web.dll /r:System.dll FirstControl.cs

The /r option informs the compiler which assemblies are referenced by your
control.

Your control is now compiled and ready to be used from any ASP.NET page in
your application's root directory (or any of its subdirectories).

So I set up the directory, open up a command window, and type all that stuff
in only to get a message "'CSC' is not recognized as in internal or external
command, operable program or batch file." This tells me either that I don't
have something registered correctly or that I'm not supposed to type all
this on a command line. If not on the command line, then where? Also, I'm
using VS 7.0 and have MSDN Universal installed on a Win2k box.

Related question: What's the difference between building the assembly this
way and going to Build: Build Solution?

I can't imagine this should be all that difficult and I'm probably missing
something very basic here. Anybody have any pointers for me?

Thanks,

Rich Evans

Reply to this message...
 
    
Andy Smith
a) it sounds to me that you don't have the path to csc.exe in your PATH =
variable.
b) if you are using vstudio, just build and copy the control to the bin =
folder as needed.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

[Original message clipped]

Reply to this message...
 
    
Chris Rickard
This one caught me originally too. You are talking about two separate ways
to do the same thing. The first way that you described compiles a dll using
the C# command line compiler. You are essentially doing the same thing when
you do a Build | Build Solution from VS .NET.

If you have VS .NET, you can open a command prompt with all the requisite
environment variables set by using the Visual Studio .NET Command Prompt on
the Visual Studio .NET Tools menu off the Visual Studio .NET main menu. All
it does is run the vsvars32.bat that was created when you installed VS.NET.
The batch file sets the path for the compiler and sets up some environment
variables that will allow the compiler to work from the command prompt and
find the .NET SDK libraries. The lack of a proper path is causing the error
you saw - the O/S doesn't know what CSC is and where to find it.

If you don't have the batch file, write me off line and I'll send it to you.

HTH

++C++

"Rich Evans" <Click here to reveal e-mail address> wrote in message news:685329@aspngvs...
[Original message clipped]

Reply to this message...
 
    
Rich Evans
That helps a lot, thanks. However, I'm still having problems using the
sample control. I took the easy way out and went to Build: Buld Solution.
This created a dll in my \FirstControl\bin directory. I copied it to my
\FirstPage\bin directory. My page is simple

<%@ Register TagPrefix="Custom" Namespace="CustomControls" Assembly =
"FirstControl" %>
<html>
<body>
<form runat="server">
Here is a custom ASP.NET server control.<br>
<br>
<Custom:MyControl Message="This control tells time. " runat="server" />
<br>
</form>
</body>
</html>

After this I get an error "File or assembly name FirstControl, or one of its
dependencies, was not found." with the @Register line highlighted. If I set
a reference to the dll, that error goes away but then I get another one
"Could not load type CustomControls.MyControl from assembly FirstPage,
Version=1.0.929.13694, Culture=neutral, PublicKeyToken=null" with the
<Custom:MyControl... line highlighted.

Something tells me that I'm not referencing the assembly correctly since I
find it hard to believe I've built it wrong--I would think it's pretty hard
to mess up Build: Build Solution. The sample control is simple, it writes a
message to the page. It declares a namespace CustomControls and it has one
public class Mycontrol. The assembly's name is FirstControl.dll.

I seem to have been caught up in something basic since this looks like it
should work. Thoughts?

Thanks,

Rich Evans

----- Original Message -----
From: "Andy Smith" <Click here to reveal e-mail address>
To: "aspngvs" <Click here to reveal e-mail address>
Sent: Wednesday, July 17, 2002 4:55 PM
Subject: [aspngvs] RE: Compiling a custom control

a) it sounds to me that you don't have the path to csc.exe in your PATH
variable.
b) if you are using vstudio, just build and copy the control to the bin
folder as needed.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

[Original message clipped]

| [aspngvs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvs.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Julian Roberts
Try this. Open up the solution explorer and click the button to show all
files. In the bin directory, right-click on your custom dll and select the
option to include the file in your project. Then go ctrl+shift+B to compile.

--
Jules
http://www.charon.co.uk

"Rich Evans" <Click here to reveal e-mail address> wrote in message news:685990@aspngvs...
[Original message clipped]

Reply to this message...
 
    
Rich Evans
It turns out that my namespace wasn't being called correctly. The tutorial
calls for Namespace="MyControl" where it should be
"CustomControls.MyControl". Why that needs to be that way I'm not sure
since Assembly='CustomControls" also needs to be in there. Oh well. It
works.

Thank you all.

Rich

----- Original Message -----
From: "Julian Roberts" <Click here to reveal e-mail address>
Newsgroups: aspngvs
To: "aspngvs" <Click here to reveal e-mail address>
Sent: Saturday, July 20, 2002 2:21 PM
Subject: [aspngvs] Re: Compiling a custom control

[Original message clipped]

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification