newbe C# Project Question

  • Thread starter Thread starter Jones
  • Start date Start date
J

Jones

I am having problems with my C# project. The project was built using VS.net
(original release with service pack 1). The project includes windows forms
and a DLL (dot.net)

After getting the application working, everything compiled and was
troubleshooted. Ready for delivery, the owner decided to change the Name of
the application and DLL.

After discussing this with another developer, we decided that the namespace
in the application needed to be changed as well.

I have changed Namespace name to the new name, DLL was renamed, and the
application was compiled several times. With clean compiles.

However, when I execute the code (in IDE or direct) the code errors out when
it attempts to access any of the DLL classes.

I have checked the references, pathing, compiling. All the possible errors
I could think of and all point to the New DLL name and Correct Namespace. I
have even checked for namespace misspellings. All have the same spelling.

Example Error Message:
" Could not load type Questionnaire.Configuration from assembly
Questionnaire, Version=1.0.1356.17027, Culture=neutral,PublicKeyToken=null,
Questionnaire"

Please Help.
 
Yes.
The DLL was recompiled several times.
In the Application project, I have even included the DLL Project and
changed the references, still with no success.
 
Do you load the DLL assembly dynamically or the acception is thrown when you
try to use a type in a "normal" way?

Anyway, what I can suggest to you is to load the dll in ILDasm tool and look
at the types your DLL exports and see if your type is among them.
 
I add the DLL to the references of the application and just reference the
classes like normal.

ie:
Survey mySurvey = new Survey();

where do I find the "ILDasm tool"?
 
In my computer ILDasm is located in:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
I believe in your too.
 
I looked in the DLL. Everything seems correct.
I looked in the application and found this:
(symbol=box) method
LoadAnswerGroup:void(class[Questionnaire]Questionnaire.AnswerGroup)

Could this be the problem, and if so, How do I fix it?
 
Frankly, I don't know what (symbol=box) menas. Maybe sombody else can help
us out with this. I haven't seen it before.
Anyway the rest of it menas:
You have method called *LoadAnswerGroup* that returns void and gets as as
its only parmeter refernce to an object of type *AnswerGroup*. AnswerGroup
is declared in *Questionnaire namaspace* in *Questionnaire assembly*.
This in turn means that the assembly has to be called Questionnaire.dll or
Questionnaire.exe
CLR will look for Questionnaire assembly in the application directory, in
<app dir>\Questionnaire sub directory or if you have config file CLR will
look also in any probing directory under <app dir>.
Make sure this assembly exist in one of those directories.

I don't know why LoadAnswerGroup method looks so suspicious to you, but I
don't think it is the broblem. This method accept reference to AnswerGroup
which menas that the type has to be already loaded when you call the method.

CLR won't attempt to load the Questionnaire assembly until the first usage
of a type defined in it. So you can step in and check if you get the error
when the application tries to use for the very first time a type defined in
Questionnaire. This will give you an idea if the error is because the CLR
fails to load the assembly or with some particular type.

B\rgds
100

Jones said:
I looked in the DLL. Everything seems correct.
I looked in the application and found this:
(symbol=box) method
LoadAnswerGroup:void(class[Questionnaire]Questionnaire.AnswerGroup)

Could this be the problem, and if so, How do I fix it?

100 said:
In my computer ILDasm is located in:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
I believe in your too.


change
the renamed,
and
 
"Symbol=Box " was the graphics in the ILDasm GUI.
The Dll is called "Questionnaire.dll"
It looked suspicious because I am not familiar with ILDASM or even very much
Dot.Net to understand what I am looking at.
The Error occurs at three locations in the application. All locations are
where the application is trying to load types from the DLL.

I have stepped through the code and know the types it is having problems
with. However, the DLL has not changed and the types have not changed. Only
the namespace has changed. The application seems to not be able to find the
DLL.

I don't know what else to check.

The reference paths include the DLL's location.
When I have both projects under the same solution, the DLL reference is
marked with "Copy Local" = True.

other than that, I have no clue where else to look.

100 said:
Frankly, I don't know what (symbol=box) menas. Maybe sombody else can help
us out with this. I haven't seen it before.
Anyway the rest of it menas:
You have method called *LoadAnswerGroup* that returns void and gets as as
its only parmeter refernce to an object of type *AnswerGroup*. AnswerGroup
is declared in *Questionnaire namaspace* in *Questionnaire assembly*.
This in turn means that the assembly has to be called Questionnaire.dll or
Questionnaire.exe
CLR will look for Questionnaire assembly in the application directory, in
<app dir>\Questionnaire sub directory or if you have config file CLR will
look also in any probing directory under <app dir>.
Make sure this assembly exist in one of those directories.

I don't know why LoadAnswerGroup method looks so suspicious to you, but I
don't think it is the broblem. This method accept reference to AnswerGroup
which menas that the type has to be already loaded when you call the method.

CLR won't attempt to load the Questionnaire assembly until the first usage
of a type defined in it. So you can step in and check if you get the error
when the application tries to use for the very first time a type defined in
Questionnaire. This will give you an idea if the error is because the CLR
fails to load the assembly or with some particular type.

B\rgds
100

Jones said:
I looked in the DLL. Everything seems correct.
I looked in the application and found this:
(symbol=box) method
LoadAnswerGroup:void(class[Questionnaire]Questionnaire.AnswerGroup)

Could this be the problem, and if so, How do I fix it?

100 said:
In my computer ILDasm is located in:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
I believe in your too.


I add the DLL to the references of the application and just
reference
the
classes like normal.

ie:
Survey mySurvey = new Survey();

where do I find the "ILDasm tool"?

Do you load the DLL assembly dynamically or the acception is
thrown
when
you
try to use a type in a "normal" way?

Anyway, what I can suggest to you is to load the dll in ILDasm
tool
and
look
at the types your DLL exports and see if your type is among them.

Yes.
The DLL was recompiled several times.
In the Application project, I have even included the DLL
Project
and
changed the references, still with no success.

Hi Jones,

Did you recompile the DLL as well?

B\rgds
100

I am having problems with my C# project. The project was built
using
VS.net
(original release with service pack 1). The project includes
windows
forms
and a DLL (dot.net)

After getting the application working, everything compiled
and
was
troubleshooted. Ready for delivery, the owner decided to change
the
Name
of
the application and DLL.

After discussing this with another developer, we decided
that
the
namespace
in the application needed to be changed as well.

I have changed Namespace name to the new name, DLL was renamed,
and
the
application was compiled several times. With clean compiles.

However, when I execute the code (in IDE or direct) the code
errors
out
when
it attempts to access any of the DLL classes.

I have checked the references, pathing, compiling. All the
possible
errors
I could think of and all point to the New DLL name and Correct
Namespace.
I
have even checked for namespace misspellings. All have the same
spelling.

Example Error Message:
" Could not load type Questionnaire.Configuration from assembly
Questionnaire, Version=1.0.1356.17027,
Culture=neutral,PublicKeyToken=null,
Questionnaire"

Please Help.
 
Jones,
I did some tests and I got FileNotFoundException if the CLR cannot locate
the assembly. If you had misspelled the namespace you had had compile time
error messages.
The only way I could get the TypeLoadException is when I did the following
1. I created application (exe) and library (dll)
2. The application uses class exported by the dll.
3. I changed the name of the type the dll exports (changing the namespace)
4. Recompiled the dll only. the exe remains the same.
5.Copied the dll in the application directory and run the application.

So what we have now is the old application which tries to import the type
form the dll. Dll has the same name version (it is not strong named) so CLR
loads it. However the type that the application tries to import doesn't
exist anymore and LoadTypeExceptions is thrown.

So I think this is your problem. Some way or another your application still
use the old dll. It compiles ok because you have provided the right path in
the references to the new dll (or project). However IDE fails to copy the
dll in the application direcotry.

Try the folowing. Recompile the new application and dll. Open the explorer
and copy the dll form
<dll project dir>\bin\debug (or release if you compile in release version)
and the <exe project dir>\bin\debug (or release) to a some new directory and
try to run the application form this new location. If it needs other
assemblies make sure to copy in the same directory latest copies of these
assemblies.

The same problem may occur if the dll referenced third assemblies and you
have the old version of it in the application directory and so on.

So the point is that when you start the Application it doesn't use what you
specified in the project references. It uses what is in the application
directory or sub directories (in case of not strongly named assemblies).

This is the role of Copy Local = true. the IDE has to copy the referenced
dll in the application directory. However, it may fail if the dll is
currently in use and the IDE won't tell anything. Try to delete the dll from
the application directory to check if the dll can be overwritten.

HTH

Jones said:
"Symbol=Box " was the graphics in the ILDasm GUI.
The Dll is called "Questionnaire.dll"
It looked suspicious because I am not familiar with ILDASM or even very much
Dot.Net to understand what I am looking at.
The Error occurs at three locations in the application. All locations are
where the application is trying to load types from the DLL.

I have stepped through the code and know the types it is having problems
with. However, the DLL has not changed and the types have not changed. Only
the namespace has changed. The application seems to not be able to find the
DLL.

I don't know what else to check.

The reference paths include the DLL's location.
When I have both projects under the same solution, the DLL reference is
marked with "Copy Local" = True.

other than that, I have no clue where else to look.

100 said:
Frankly, I don't know what (symbol=box) menas. Maybe sombody else can help
us out with this. I haven't seen it before.
Anyway the rest of it menas:
You have method called *LoadAnswerGroup* that returns void and gets as as
its only parmeter refernce to an object of type *AnswerGroup*. AnswerGroup
is declared in *Questionnaire namaspace* in *Questionnaire assembly*.
This in turn means that the assembly has to be called Questionnaire.dll or
Questionnaire.exe
CLR will look for Questionnaire assembly in the application directory, in
<app dir>\Questionnaire sub directory or if you have config file CLR will
look also in any probing directory under <app dir>.
Make sure this assembly exist in one of those directories.

I don't know why LoadAnswerGroup method looks so suspicious to you, but I
don't think it is the broblem. This method accept reference to AnswerGroup
which menas that the type has to be already loaded when you call the method.

CLR won't attempt to load the Questionnaire assembly until the first usage
of a type defined in it. So you can step in and check if you get the error
when the application tries to use for the very first time a type defined in
Questionnaire. This will give you an idea if the error is because the CLR
fails to load the assembly or with some particular type.

B\rgds
100

Jones said:
I looked in the DLL. Everything seems correct.
I looked in the application and found this:
(symbol=box) method
LoadAnswerGroup:void(class[Questionnaire]Questionnaire.AnswerGroup)

Could this be the problem, and if so, How do I fix it?

In my computer ILDasm is located in:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
I believe in your too.


I add the DLL to the references of the application and just reference
the
classes like normal.

ie:
Survey mySurvey = new Survey();

where do I find the "ILDasm tool"?

Do you load the DLL assembly dynamically or the acception is thrown
when
you
try to use a type in a "normal" way?

Anyway, what I can suggest to you is to load the dll in ILDasm tool
and
look
at the types your DLL exports and see if your type is among them.

Yes.
The DLL was recompiled several times.
In the Application project, I have even included the DLL Project
and
changed the references, still with no success.

Hi Jones,

Did you recompile the DLL as well?

B\rgds
100

I am having problems with my C# project. The project was built
using
VS.net
(original release with service pack 1). The project includes
windows
forms
and a DLL (dot.net)

After getting the application working, everything compiled and
was
troubleshooted. Ready for delivery, the owner decided to change
the
Name
of
the application and DLL.

After discussing this with another developer, we decided that
the
namespace
in the application needed to be changed as well.

I have changed Namespace name to the new name, DLL was renamed,
and
the
application was compiled several times. With clean compiles.

However, when I execute the code (in IDE or direct) the code
errors
out
when
it attempts to access any of the DLL classes.

I have checked the references, pathing, compiling. All the
possible
errors
I could think of and all point to the New DLL name and Correct
Namespace.
I
have even checked for namespace misspellings. All have
the
same
spelling.

Example Error Message:
" Could not load type Questionnaire.Configuration from assembly
Questionnaire, Version=1.0.1356.17027,
Culture=neutral,PublicKeyToken=null,
Questionnaire"

Please Help.
 
I tried the suggestions,
I compiled each project. Copied each assembly (exe and DLL) to a new
directory and ran the application. Still getting the same errors.
Any other possible help?
 
Wow, no more ideas ;(
If you have time and you can reproduce the same in a test project you can
send it to me. I'll try to find what the problem is. My email address is
*sgoutsev<?>dromeydesign.com* just repalce <?> with @
What I can say is that CLR finds the DLL and loads it, but the a type is not
in the DLL.

B\rgds
100
 
Back
Top