Can't load assemblies in IDE

J

Jack Jackson

This is driving me crazy and I am stuck. I'm using VS2005 and VB.

I have four projects, each of which creates a .dll.

Proj1 has no project references.
Proj2 has a project reference to Proj1.
Proj3 has a project reference to Proj2 and Proj1.
Proj4 has a project referecne to Proj3, Proj2 and Proj1.

Proj4 contains a class Class1 derived from System.Windows.Forms.Form,
and another class Class2 derived from Class1.

Proj5 creates an .exe. It has a form inherited from Class2.

Originally all projects had the default version of 1.0.0.0, and
everything worked fine.

I then changed the version of Proj1 to 1.0.0.* and rebuilt everything.
While the .exe runs fine, I can't view the design view of any class
that is derived from Class2. The error I get is below at the bottom
of the post. Closing VisualStudio doesn't help.

If I change the version of Proj1 back to 1.0.0.0, everything again
works fine. The same thing happens if I change the version of Proj2,
Proj3 or Proj4.

In addition, if I create a new project, add Proj1, Proj2, Proj3 and
Proj4 as references and try to add a class based on an inherited form,
I get an error message box:

"Unable to load assembly xxx. Ensure that the file is a valid .NET
Framework Assembly."

for each of Proj2, Proj3 and Proj4.

For some reason the IDE can't load classes from anything that depends
on Proj1 once its version is changed, yet everything works fine at
runtime.

I am at my wit's end with this. Any ideas?


The IDE gives this error when I try to view the Design view of any
class derived from Proj4's Class2:

One or more errors encountered while loading the designer. The errors
are listed below. Some errors can be fixed by rebuilding your project,
while others may require code changes.

The designer could not be shown for this file because none of the
classes within it can be designed. The designer inspected the
following classes in the file: Proj4 --- The base class
'ZForms.Class1' could not be loaded. Ensure the assembly has been
referenced and that all projects have been built.
Hide

at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager
manager)
at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager
serializationManager)
at
System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost
host)
 
C

Cor Ligthert[MVP]

Jack,

If you use the DLL from other projects that are in your solution, than you
have first to build them while there are then no errors in it. As long as
that not is done or you are pointing to a wrong DLL this will not be used.
You know that you can point as well to the projects in your sollution as
well by setting that in the add reference box?

(This can be done by the build parameters as well, be sure they are in the
right sequence)

(What you build has to be without errors)

Cor
 
J

Jack Jackson

As I said in the original post, I have rebuilt all projects. I also
said that all references are project references.

After rebuilding, all projects show the new version number for Proj1
in the References. All builds complete with no errors.

Everything works fine except that after I change the version in Proj1,
I can't display the design view of any class that derives from Class2.
Changing the version of Proj1 back to 1.0.0.0 makes the errors go
away.
 
M

Matt F

Jack,

A couple of things you might want to try:
1: Clean your solution from the build menu, and do a complete rebuild.
I've had issues like this in the past where that solution has fixed the
issue.
2: Take a look very carefully at the Proj4.Class2.designer.vb code --- the
error is may be apparent there.
3: In the configuration manager, double check and make sure that all
projects are selected to be built.
4: Check the dependencies in solution properties ---
(right click on the solution then select properties --- select "project
dependencies" in the tree, then select each project from the drop down and
make sure all references are what you would expect.)

If you don't mind, post back the results --- I'm curious about this one.
 
J

Jack Jackson

Jack,

A couple of things you might want to try:
1: Clean your solution from the build menu, and do a complete rebuild.
I've had issues like this in the past where that solution has fixed the
issue.
2: Take a look very carefully at the Proj4.Class2.designer.vb code --- the
error is may be apparent there.
3: In the configuration manager, double check and make sure that all
projects are selected to be built.
4: Check the dependencies in solution properties ---
(right click on the solution then select properties --- select "project
dependencies" in the tree, then select each project from the drop down and
make sure all references are what you would expect.)

If you don't mind, post back the results --- I'm curious about this one.

Cleaning didn't help. I even tried deleting everything in the bin
directory, that didn't help either.

I can't see anything unusual in the designer.vb code.

What really confuses me about this is that the only thing that doesn't
work is instantiating the classes in the IDE. I can run it OK. And
if I change the version of Proj1 back to 1.0.0.0 it works fine in the
IDE. It's clearly related to the version, but how?

I'm really worried by this because I am doing preliminary work for
what will be a large application. If we can't change the version it
will be a disaster.
 
C

Cor Ligthert[MVP]

Jack,

Did you renewed the references to the new versions (and removed the old). I
do not know how you did it, but by instance Microsoft has often many
versions in the DLL. If you don't change that, you keep the one you have
choosen.

Cor
 
J

Jack Jackson

They are Project references, so it should not be necessary to renew
them. However, I did try removing and adding them back and it didn't
help.

It runs fine an as executable. It's just in the IDE that it won't
display the forms. That must be a clue as to what is going on.
 

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