VS will not open control since dll update

I look in many places, including google and SO, but I did not find the answer.

I recently made several changes to my application, including updating the dll (from 5.1.4.26270 to 5.1.6.405), and since VS will not open my controls, throwing this error:

Failed to load file or assembly "ZedGraph, Version = 5.1.4.26270, Culture = neutral, PublicKeyToken = ..." or one of its dependencies. The system cannot find the specified file.

Which point refers to the old version. I look everywhere, I do not see any traces of this old version.

It also throws this error:

The variable 'lineGraphControl1' is either not declared or has never been assigned.

While I call the constructor:

this.lineGraphControl1 = new Sakura.UI.Graphing.LineGraphControl(); 

I have tried:

  • Reboot
  • Clean and reboot
  • Launch VS in administrator mode.
  • Delete link and re-add it

Without success.

How to erase the trace of the old ZedGraph library and how can I fix this error?

Edit

Here are the changes between old and new (old)

 <Reference Include="ZedGraph, Version=5.1.4.26270, Culture=neutral, PublicKeyToken=02a83cbd123fcd60, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\ZedGraph.dll</HintPath> </Reference> 

 <Reference Include="ZedGraph, Version=5.1.6.405, Culture=neutral, PublicKeyToken=02a83cbd123fcd60, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\ZedGraph.dll</HintPath> </Reference> 

Edit 2

After clearing the VS cache and restarting the computer, the error message changed:

 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 Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) 

I'm lost.

Edit 3

I scan the entire disk for line 5.1.4.26270 , and the only place found is not in the project.


csproj snippet:

 <Reference Include="ZedGraph, Version=5.1.6.405, Culture=neutral, PublicKeyToken=02a83cbd123fcd60, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\ZedGraph.dll</HintPath> </Reference> 

Change 4:

(After Hans Passant anwser)

Here's the declaration of LineGraphControl:

 public class LineGraphControl : GraphControl<Sakura.Graphing.LineGraph> 

LineGraph (which uses ZedGraph objects)

 public class LineGraph : Graph, ISerializable 

Schedule:

 [XmlInclude(typeof(StackedGraph))] [XmlInclude(typeof(LineGraph))] [XmlInclude(typeof(BubbleGraph))] [XmlInclude(typeof(BatchGraph))] [Serializable] public abstract class Graph : ISerializable 

Unfortunately, ZedGraph lib is deeply associated with the software in order to change it to another.

I will not refuse changes, because I adapt the library in such a way as to make my software 250% faster.

This is where a preliminary call is made to open LineGraphControl in VS:

 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) 

Here is the activity log

Error message when trying to create a new LineGraphControl :

enter image description here

ProcMon Instance:

enter image description here

+6
source share
3 answers

Problem

Error - this file was not found , like the one with which I helped with another day:

Failed to load file or assembly. The system cannot find the specified file.

Troubleshooting

Open ProcessMonitor and start it when VS does not allow you to open controls and throws an error. Stop the trace when it does not work, and check the ProcMon (Filemon) log to find out where the IDE is looking for a DLL that it cannot find.

Decision

Put the DLL where you expected to find it (this, we hope, sorts the VS library that references the failure).


The process monitor helped identify the strange ZedGraph.dll link in the directory of the Resharper plugin. I have completed the following steps:

  • disable resharper
  • restart VS
  • clean and rebuild
  • re-enable resharper
  • Smile
+2
source

There is no code, no exception messages, no hint that there might be a "LineGraphControl", it is very difficult for you to help you. I looked at the ZedGraph project to see what could be causing you trouble.

There is no shortage of this; there are quite a few problems with this control. There is very little evidence in the code that the author understood serialization of development time. Many properties that are visible in the properties window should not be visible, cannot be edited (grayed out) and accept changes, but are not serialized. Some properties are correctly hidden, hinting that this was obtained from trial and error.

Most seriously, almost every class in a project is binary-serialized. Either the [Serializable] attribute, or implementing the ISerializable attribute. But without regard to the version-independent serialization, the [AssemblyVersion] attribute changes for each individual version of the control with an effective version number depending on the time of the assembly day of the assembly. This is what I found in the downloaded version:

  [assembly: AssemblyVersion( "5.1.5.*" )] 

What is the worst possible version strategy you could choose, it doesn't even guarantee a steadily increasing number. In particular, it is fatal when you inherit your own control from ZedGraphControl and set your properties yourself, without using the author's trial and error method. Winforms really loves classes that are serializable, which makes it easy to save objects during development. But with the result that you describe when changing the assembly version, what was previously serialized can no longer be deserialized. Kaboom, when you try to open a user control or a form containing a control, Visual Studio can no longer find the required assembly.

And yes, this version number is hard to find back, it was embedded in the line inside the .resx file, which is part of your project. Created by encoding serialized bytes using Convert.ToBase64String (). This line is just a random letter of letters, you cannot find out the version number from it.

So specific advice:

  • After a bite twice shy, using this control, it is a huge responsibility. Consider something else, the .NET Framework Chart control is pretty decent.
  • Discard the updated version and restore the original, easiest fix, of course.
  • Go to the control source and add it to the solution. Modify the AssemblyInfo.cs file and hardcode "5.1.4.26270" in the [AssemblyVersion] attribute.
  • This should help a lot, but does not guarantee that previously serialized data can still be deserialized, the class can change. Then you need to break through the .resx files of your user control and the forms that use it, and look for Base64 strings. Write a small program that decodes the string to verify that you have found the correct one. And delete the entry from the .resx file.
  • If this does not turn off, you need to manually edit the Designer.cs file. Remove any statement that references the control. Then you can open it in design mode and add the control back.
+4
source

It is possible that another dependency in your project still specifically references the old version of the assembly.

What about an assembly / DLL where Sakura.UI.Graphing.LineGraphControl is defined?

0
source

Source: https://habr.com/ru/post/980991/


All Articles