Solved

System.IO.FileNotFoundException in C#

Posted on 2008-10-24
8
844 Views
Last Modified: 2013-12-17
Hi All,

Iam trying to load a WPF on to Window Forms.
I have created a control created using XAML and I have the project compiled with the 'Output Type' as 'Class Library'.

I have another project that displays Windows Form.
Iam adding the dll of the WPF control in the add reference of this project.
(The directory structure is also fine.)

When I complie and run the project, i have the runtime error.

"System.IO.FileNotFoundException: Could not load file or assembly ' XXX, Version=1.0.3219.20825, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: XXX, Version=1.0.3219.20825, Culture=neutral, PublicKeyToken=null'
at MainWindow_Load(Object sender, EventArgs e) "

The code of my Window_Load looks like this.

       private MyControls.Page1 wpfAddressCtrl;

        private void MainWindow_Load(object sender, EventArgs e)
        {
            ctrlHost = new ElementHost();
            ctrlHost.Dock = DockStyle.Fill;
            panel1.Controls.Add(ctrlHost);
            wpfAddressCtrl = new MyControls.Page1(); //(Page1 is the class name in MyControls project)
            wpfAddressCtrl.InitializeComponent();
            ctrlHost.Child = wpfAddressCtrl;
        }

Could any one solve this problem.?

Thanks in Advance
Yateesh
0
Comment
Question by:yateesh
  • 4
  • 4
8 Comments
 
LVL 13

Expert Comment

by:TechTiger007
Comment Utility
Your application is trying to load the assembly"XXX" and it is unable to find it. Check if this assembly is in bin folder or GAC
0
 

Author Comment

by:yateesh
Comment Utility
The assembly file 'xxx.dll' is present in my bin\Debug and bin\Release folder.
I didnt get what does "GAC" means...is it compulsary to load here also.?
0
 
LVL 13

Expert Comment

by:TechTiger007
Comment Utility
do you have this dll in bin/debug and bin/release folder of the project that you are running?
GAC - global assembly cache, ie. c:\windows\assembly.
if you have the dll in bin folders then its fine you dont have to look in GAC
0
 

Author Comment

by:yateesh
Comment Utility
No..the dll is in its own project folder(XXXProj).
But the project folder which iam running and the folder containing the project for 'xxx.dll' are in the same folder called "New Folder''.

NewFolder\NowRunnning  and  NewFolder\XXXProj.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:TechTiger007
Comment Utility
Copy this dll to now running application's bin folder. Because now running application will look into its bin folder for the dlls
0
 

Author Comment

by:yateesh
Comment Utility
Hi TechTiger007,

When I added the XXX.dll as the reference, the dll is automatically gets added  to the running application's 'bin' folder.
I also crossed checked and i could see that the XXX.dll is present in the running application's 'bin' folder.
0
 
LVL 13

Expert Comment

by:TechTiger007
Comment Utility
So now we have the dll in bin folder but still visual studio gives this error. hmm.

Probably this could be due to the bug in visual studio.  Try to disable the binding exception as mentioned in the below link
http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_2.0/Q_23829974.html
0
 

Accepted Solution

by:
yateesh earned 0 total points
Comment Utility
I displayed the WPF user control directly instead of loading this on the form. and this helped me in serving my purpose.
thanks TechTiger007 for your comments.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now