Solved

Could not load file or assembly or one of its dependencies. The system cannot find the file specified.

Posted on 2009-06-28
11
10,005 Views
Last Modified: 2012-05-07
This looks like a bug by microsoft, it is pretty annoying and I'm wondering if anyone has a solution, or maybe I'm doing something wrong (And in this case, what am I doing wrong and how to do it right)

I have noticed that on several user controls that I've created... some projects that had the user control on a form were giving this error when opening the solution... it will happen if the form that contained the user control was opened.

Closing the form and reopening it would "fix" the problem (The error will be gone).

At first I thought I did something wrong and started investigating... after I didn't find anything I did some tests and in one of them I found out that removing one of the projects from the solution and then adding it back solved the problem... Off course this has no sense so I started checking why got changed... It seems that the only difference is in the Solution file.



I've made a simple example:
http://rapidshare.com/files/249837223/BigMike.rar.html



(Sorry for  the stupid/weird names... I've ran out of reasonable names)

Open BigMike solution. You should see that you get an error
Open BigMike2 solution. You should see that it opens OK without any error.

The only difference between those 2 is the order of the projects in the solution, which ultimately cases the error:

Could not load file or assembly 'RedEye, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Instances of this error (1)  
 
1.   Hide Call Stack
 
at BigMike.Mike..ctor()  


It claims that it fails on the constructor.


I see no reason why the projects order would prevent loading an assembly.

I'm using Visual Studio 2008 if that matters.

Thank you.
0
Comment
Question by:saragani
  • 6
  • 4
11 Comments
 
LVL 11

Expert Comment

by:William
ID: 24735598
I have opend both without errors...
Can you try something for me...
In the IDE open the solution that gives you error.
In solution explorer, right click the top node 'solution itself' and click clean.
rebuild solution and try again to open.
Thanks
0
 
LVL 11

Author Comment

by:saragani
ID: 24735739
Same thing (problem is not solved)

When you opened the projects Form1 was opened?

If not then:
1) Open the "BigMike" solution by double clicking the sln file.
2) Double click on Form1 to show it's design.
3) Close visual studio
4) Double Click on the sln file again.

0
 
LVL 11

Author Comment

by:saragani
ID: 24735789
I've just tested it on a coworker's computer and he gets the same problem.
He has a totally different computer, with Vista (and not XP like me), and he has different softwares installed on his computer.


It means that you should be able to recreate the problem in your computer using the steps I wrote above.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 11

Expert Comment

by:William
ID: 24735815
When you are adding references to these assemblies, how are you adding them?
0
 
LVL 11

Author Comment

by:saragani
ID: 24736000
Using visual studio --> Add reference --> Browse -->  Selecting the DLL.

How else would I do it... Manually? (I'm not that insane).
0
 
LVL 11

Author Comment

by:saragani
ID: 24736399
Did you manage to see the problem that I saw talking about using the instructions I gave?

If so then you can code your own projects and see the problem:

1) Create a user control project.
2) Add a new Class Library project to that solution or add a reference to an existing DLL.
3) Make the user control does something with the DLL (so it will be compiled by the JIT, if it's not needed then it doesn't help). Have that code be after the call for the InitializeComponents (I don't know if that matters). (For example create a new instance of a class of that DLL)
4) Compile the user control

5) close that solution

6) Create a new solution with a Class Library project.
7) Add a new WinForms project to that solution
8) Add the user control that you have created to the toolbox
9) Add the user control to Form1
10) Since I assume that a reference to the DLL that you have created earlier (the one that the user control reference to) was not added to the references of the Winforms project, then add it to the Winforms project
11) In the constructor of the form, create a new instance of a class of that DLL.
12) Compile
13) Double click on Form1 so the design will be visible
14) Close the solution
15) Open the solution


You get the error:

"Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.    
 

Instances of this error (1)  
 
1.   Show Call Stack  
 
at bbb.UserControl1..ctor()  
   
Help with this error  
 
Could not find an associated help topic for this error. Check Windows Forms Design-Time error list  
   
Forum posts about this error  
 
Search the MSDN Forums for posts related to this error  

 
The variable 'userControl11' is either undeclared or was never assigned.     Go to code  
     
Instances of this error (1)  
 
1.   ppp Form1.Designer.cs Line:47 Column:1   Show Call Stack  
 
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)  
   
Help with this error  
 
MSDN Help  
   
Forum posts about this error  
 
Search the MSDN Forums for posts related to this error"
0
 
LVL 11

Accepted Solution

by:
William earned 500 total points
ID: 24736527
Yes - I did not mean you were insane :) - I have this problem in the past, and when I would ref the dll directly...  it does not always like it. So I reference the projects instaed.
THis solves the issue and allows me to debig as well.
 
YES -I saw the error after I opened the form .. closed.. and reopened.
Try referenceing the proj files instead of the dll's.
Unless the dll is actually a production release use the proj. If it is in production release...  and it is a USER CONTROL or a COMPONENT --  Add theses types to the toolbar and drag them to your form.
0
 
LVL 11

Author Comment

by:saragani
ID: 24736651
Yes, I don't that referring the project helps (I did this in the past), but the user control and the DLLs that I create are meant to be deploys for the usage of other people.

They will not use the project itself but the assemblies.

As I already mentioned, adding to the toolbar doesn't help (This is how I've added it to the form in the first place).
The problem is that the User Control constructor fails because of the DLL it refers. :-(
The funny thing is that if you got that error and then you close the form and reopen it then everything is OK.
 
Adding my assemblies to the GAC might solve the problem, but this is something I prefer not to do.


Is there anything else I can try to solve this problem?
0
 
LVL 11

Author Comment

by:saragani
ID: 24736687
Anyway, leave your comment here for any suggestions you might have of solving this error (Or maybe how to contact microsoft and report about this issue).

I'm giving you these points because you tried to help.

Feel free to suggest some other solutions if you think of them.


Thank you :-)
0
 
LVL 11

Expert Comment

by:William
ID: 24736794
Do you have a namespace architecture you are using....
Mikes
Mikes.RedEeye
Mikes.BigGuy
ect....
The issue I see is not a MS issue, but one I have had in the past that is:
The DLL the proj is referencing, references another dll outside the namespace... and is not 'pulled' in untill a build is performed. If you can roll these into a single dll or create a namespace hiearchy with a 'release' folder that all the dll'soutput too. this may solve the issue.
In your solution you can change the output dir to anything you like, I have my own 'wannabe' framework that I dump to the same dir after every build. THis ensures every proj I use them in pulls in the latest.
I also add a pre build line to the proj.
erase *.dll
this removes all dll's proir to the build and pulls in the latest.
Hope this helps and thanks for the points
0
 
LVL 1

Expert Comment

by:anugrah
ID: 31717420
I am using a WCF service, I have hosted the WCF service as a Managed windows service, so that on start of the Windows service the WCF service will be invoked and I am calling this wcf service through a a windows app(a winforms) as the service is responsible for the database connection.But is showing the same error,
Could not load file or assembly 'MSDOTNET.MSDB" (which is a our conpany own framework assembly.)
or one of its dependencies.The system cannot find the file specified,
Any help would be highly appreciated.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question