Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use Winforms control because of unresolved dependencies

Problem: I have a WinForms control ('MyControl') with a dependency on myCli.dll, a dll written in C++ CLI. This component is third party (written by another team). myCli.dll has a dependency on myLibrary.dll which is written by yet another party. The control lives in myAssembly.dll, which is a C# controls and resources library.

I had this control working great when myCli.dll didn't have a dependency on myLibrary.dll. I could add it to forms, build it, and so on. But the new version of myCli.dll came out and I relinked against it. Suddenly, the IDE is behaving badly. The key issue appears to be that the IDE is unable to resolve the myCli.dll dependency on myLibrary.dll.

When I attempt to drag the control from the toolbox to a design surface, I get the error:

"Failed to create component 'MyControl'.  

The error message follows:

'System.IO.FileNotFoundException: Could not load file or assembly 'myCli.dll, Version 0.0.0.0, Culture=neutral, PublicKeyToken=2fb8da784abc560a' or one of its dependencies. 
The system cannot find the file specified"

My belief is that if I can figure out where to put myLibrary.dll, I will resolve the reference issue. I don't know this for sure. Does someone know what I should do to resolve the issue?

like image 640
MedicineMan Avatar asked Nov 14 '22 15:11

MedicineMan


1 Answers

In my case my code on Initialize and Form_Load contained calls to another project depending on DLL references. By excluding this code with

if (!DesignMode)
{
    //add your initializing code (for runtime!) here
}

I was able to add the control on design time.

HTH

like image 182
Peter Rakké Avatar answered Dec 05 '22 17:12

Peter Rakké