VC# .NET 2003 refuses to make a Windows DLL that is not a web DLL

W

Will Pittenger

I am attempting to reuse code. Some of the code is such that I need a base
class for my forms. I know that those base classes must be in a DLL.
However, if I create a "Class Library" project, I get a DLL, but only one
that omits System.Windows. It does have a lot of useless (for me) web stuff
in System.

The topic
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconWindowsControlLibraryTemplate.htm
refers to a New Project Wizard that appears to be missing. In
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbwlkwalkthroughdemonstratingvisualinheritance.htm,
we are told to create a "Windows Application" and then, in the properties
for the project, set "output type from Windows Application to Class Library
and click OK". I can find no such property anywhere in my solution or
project.

What gives? I am running VC# .NET 2003 Standard.
 
G

Guest

Hi Will,
if you right click on your project and choose properties form the context
menu you will get the properties box. Select the "General" tree item which
is located under the "Common Properties" folder. You will then see on the
right hand side an option for "Output Type" which you can change to class
library.

Hope that helps.
Mark.
 
G

Guest

Unfortunately I cannot see the screen shot, you can send it to my gmail
account (e-mail address removed)
 
D

David McCabe

See below.

Will Pittenger said:
I am attempting to reuse code. Some of the code is such that I need a base
class for my forms. I know that those base classes must be in a DLL.
However, if I create a "Class Library" project, I get a DLL, but only one
that omits System.Windows. It does have a lot of useless (for me) web
stuff in System.

System, System.Data and System.XML are automatically added to new Class
Library projects. To add a reference, click the Project menu, Add Reference,
and select System.Windows.Forms.dll from the list. If you add a new Windows
Form it should automatically add this reference.

I am using 2003 Pro, so YMMV.
The topic
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconWindowsControlLibraryTemplate.htm
refers to a New Project Wizard that appears to be missing.

Quote: Note This project type is not available in the Standard Edition of
Visual Basic and Visual C# .NET.
 
W

Will Pittenger

Adding the reference lets the project compile and run. I can open the base
class form successfully. (I have yet to add any pure virtual stuff.) There
were two problems. First, I could not get the one of the DLL projects to
start the program when it is the startup project (rather than the app's
project). Second, the IDE doesn't treat the base class as a form in the
editor. Ditto for the derived class.
 
D

David McCabe

See below.

Will Pittenger said:
Adding the reference lets the project compile and run. I can open the base
class form successfully. (I have yet to add any pure virtual stuff.) There
were two problems. First, I could not get the one of the DLL projects to
start the program when it is the startup project (rather than the app's
project).

How do you expect the DLL to run as the startup project? DLLs are libraries
and don't have entry points, and cannot be run standalone.
Second, the IDE doesn't treat the base class as a form in the editor.
Ditto for the derived class.

Excluding the file from the project, then re-including it, should cause VS
to re-read the base class and figure out that the file is actually a Form.
 
W

Will Pittenger

DLL's projects can be debugged by starting another program. There is an
option in the properties that you set to tell Visual Studio to run another
program or open a webpage (if you are doing a web dll) when you start the
project.

I will check on the form issue and get back to you.
 
W

Will Pittenger

It turns out that I can now edit the base class with the editor. However,
when I open the derived class, the IDE complains that the overload of
constructors is not supported. So no changes there.
 
D

David McCabe

The IDE can only open form classes with a no-params constructor IIRC
(actually, there may be other acceptable ones I have forgotten). Add a
default constructor; you can always remove it or #if it out when you're done
with the form editor.
 
W

Will Pittenger

No luck there. I already had the following constructor.

public formNewListsDrivers()
{
//
// Required for Windows Form Designer support
//

InitializeComponent();

throw new System.InvalidOperationException("This constructor overload for
formNewListsDrivers is not supported");
}
 
D

David McCabe

Sorry, I should have mentioned that the *base* class needs the default
constructor, not the derived class. AFAIK VS instantiates the base class and
then executes the code in InitializeComponent on the instance of the base
class to create the designer components.

If I have Form2 derived from Form1, Form2 can have any old constructor, but
Form1 must have a default constructor, otherwise I get "An exception
occurred while trying to create an instance of WindowsApplication5.Form1.
The exception was "Constructor on type WindowsApplication5.Form1 not
found."."
 
W

Will Pittenger

Actually, I had the following constructor in the base class. I used it to
create the one I gave you for the derived class. In fact, when I posted
that other constructor, I noticed that the code throwing the exception
referred to the base class rather than the derived class. This is the base
class

public recCollectionEditingForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

throw new System.InvalidOperationException("This constructor overload for
recCollectionEditingForm is not supported");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top