6

I've look in many places including google and SO but I didn't find any relevant answer.

I've made a few changes in my app recently, including updating ZedGraph dll (from 5.1.4.26270 to 5.1.6.405) and since, VS won't open my controls throwing this error:

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

Which point to the old version. I've look everywhere, I don't find any trace of this old version.

It also throw this error:

The variable 'lineGraphControl1' is either undeclared or was never assigned.

Whereas I call the constructor:

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

I've try to:

  • Reboot
  • Clean and Rebluid
  • Start VS in admin mode
  • Remove the reference and re-add it

Without success.

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

Edit

Here's the changes between the old version and the new (old first)

<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 cache of VS and rebooting 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 am lost.

Edit 3

I've search through the whole disk for the string 5.1.4.26270 and the only place found are 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>

Edit 4:

(After Hans Passant anwser)

Here's the LineGraphControl declaration:

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

The LineGraph (which use ZedGraph objects)

public class LineGraph : Graph, ISerializable

The Graph:

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

Unfortunately the ZedGraph lib is to deeply linked to the software to change it to another one.

I won't rollback the changes because I've adapt the library in a way that make my software graphing 250% faster.

Here's the callstack of the tentative to open the 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's the activity log

Error message when I try to create a new LineGraphControl:

enter image description here

The ProcMon extract:

enter image description here

Community
  • 1
  • 1
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
  • Remove the reference and re-add it, Or you can edit the project file to change the reference. The first approach is the safe on though. – Styxxy Jan 14 '15 at 13:28
  • @Styxxy it didn't worked :/ – Thomas Ayoub Jan 14 '15 at 13:30
  • In your references properties what are the value for Local Copy, Specific Version and is your Path correctly assign ? – Maxime Mangel Jan 14 '15 at 13:45
  • 1
    Could you post a snippet of you csproj-file showing the reference there? Just to speculate here is a keyword: "hintpath". – Alexander Schmidt Jan 14 '15 at 13:45
  • Did you try to regenerate the whole solution ? It's should update the path, and rebuild the whole project. – Maxime Mangel Jan 14 '15 at 13:55
  • @MaximeMangel like `Rebuild` ? – Thomas Ayoub Jan 14 '15 at 13:57
  • Yes, I think it's the same things in fact... – Maxime Mangel Jan 14 '15 at 13:59
  • @Thomas what error do you get if you add the old reference? – U r s u s Feb 03 '15 at 10:07
  • @Ursus you mean if I rollback my changes ? – Thomas Ayoub Feb 03 '15 at 10:08
  • @Thomas Yep. Does it work correctly if you do that? – U r s u s Feb 03 '15 at 10:09
  • @Ursus well, I guess, but it's a long process to do so, are you sure this can change something ? – Thomas Ayoub Feb 03 '15 at 10:12
  • @Thomas why would it be a long process? I thought you're just updating the reference by adding/removing the dll.If it works fine it would hint to the fact that there's an issue with the newer version. – U r s u s Feb 03 '15 at 10:17
  • @Ursus because I've made a few changes in the library which are now widely exploited in my code, the rollback isn't just a copy/paste stuff, that's why I asked you if you're kind of sure about this – Thomas Ayoub Feb 03 '15 at 10:20
  • @Thomas Fair enough. But then perhaps the cause is in the "few changes in the library" you've made. Are you still getting the same issue as described in you Edit3? – U r s u s Feb 03 '15 at 10:25
  • Try to create the log of VS, launch VS with log parametr: `C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE>devenv.exe /Log` and you'll find in the log here: `C:\Users\User\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml` – crea7or Feb 03 '15 at 15:51
  • @crea7or where should I host it ? – Thomas Ayoub Feb 03 '15 at 16:10
  • Have you tried removing and adding the control? Sorry if it sounds dumb, I read all the answers and comments and didn't find any reference to doing that. – João Miguel Brandão Feb 03 '15 at 16:14
  • @Thomas try this file sharing service http://nekaka.com – crea7or Feb 03 '15 at 16:18
  • I would reread and carefully study Mr Passant's answer. The Control is constructed in a very amateur manner (SaveFileDialog as a design property?, `Selection` is a RO collection, but shows as a prop (and crashes); whatever `YScrollRangeList` is, it is not serializing anything added via the collection editor - it is not RO so it is not clear if it is a RT prop that shows by accident). With that kind of sloppiness (plus the fatal versioning) are you sure you want to bet that there is not more hiding around other corners? – Ňɏssa Pøngjǣrdenlarp Feb 03 '15 at 17:36
  • is it a x64 bit dll ? if so you cannot open the designer view, Try changing the target to `Any CPU` – Vignesh.N Feb 04 '15 at 08:12

3 Answers3

5

No code, no exception message, no hint what a "LineGraphControl" might be, you make it pretty difficult to help you. I took a look at the ZedGraph project to see what might get you into trouble like this.

No lack of that, there are rather a lot of problems with this control. The code shows very little evidence that the author understood design-time serialization. Lots of the properties that are visible in the Properties Window should not have been visible, are not editable (grayed out) and do accept edits but don't serialize. Some properties are correctly hidden, hinting that this was arrived at with trial and error.

Most severely, almost every single class in the project is binary-serializable. Either by the [Serializable] attribute or implementing ISerializable. But without any regard for version-independent serialization, the [AssemblyVersion] attribute changes for every single version of the control with the effective version number depending on the time of day that the assembly was built. This is what I found in the version I downloaded:

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

That's the worst possible version strategy you could pick, it doesn't even guarantee a steadily increasing number. In particular lethal when you inherit your own control from ZedGraphControl and expose properties yourself, without the benefit of the author's trial and error approach. Winforms really likes classes that are serializable, it makes it easy to persist their objects at design time. But with the kind of outcome you describe when the assembly version changes, what was previously serialized cannot be deserialized anymore. Kaboom when you try to open the user control or the form that contains the control, Visual Studio cannot find the required assembly anymore.

And yes, that version number is hard to find back, it was embedded in a string inside a .resx file that's part of your project. Created by encoding the serialized bytes with Convert.ToBase64String(). That string is just a random blob of letters, you cannot recognize the version number from it.

So specific advice:

  • Once bitten, twice shy, using this control is a huge liability. Consider something else, the .NET Framework Chart control is fairly decent.
  • Give up on the updated version and restore the original, the simplest fix of course.
  • Check-in the source of the control and add it to the solution. Edit the AssemblyInfo.cs file and hard-code "5.1.4.26270" in the [AssemblyVersion] attribute.
  • That ought to help a lot but is not a guarantee that the previously serialized data can still be deserialized, the class might have changed. You then need to dig through the .resx files of your user control and the forms that use it and look for the Base64 strings. Write a little program that decodes the string to double-check that you found the correct one. And delete the entry from the .resx file.
  • If that doesn't pan out either then you have to edit the Designer.cs file(s) by hand. Delete any statement that references the control. You should then be able to open it in design-mode and add the control back.
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I'd upvote if it wasn't a Community Wiki post.. whats going on Hans? First its answering bounties with comments and now community wiki's? You have to take *some* credit.. – Jeremy Thompson Feb 04 '15 at 08:30
2

Problem

The error is a file not found, like the one I helped out with the other day:

Could not load file or assembly .. The system cannot find the file specified.

Troubleshooting

Open ProcessMonitor and run it when VS won't let you open your controls and throws the error. Stop the trace when it fails and investigate ProcMon's (Filemon) log to see where the IDE is looking for the DLL it cant find.

Solution

Put the DLL where its expected to be found (this will hopefully sort out the VS library referencing failure).


The process monitor helped to spot a wierd reference of ZedGraph.dll in the Resharper plugin directory. I've followed this steps:

  1. disable Resharper
  2. restart VS
  3. clean & rebuild
  4. enable Resharper again
  5. smile
Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • See edit, please tell me if this is a normal behavior or not :) – Thomas Ayoub Feb 04 '15 at 08:33
  • I like to export as a CSV > into Excel > Filter (on all columns) > then fine tune the filters for the Result column to only include warnings like *file not found* or *access denied* or ... the other thing I llke to do is use ProcMons > right click > "Jump To" and see what version it is using. – Jeremy Thompson Feb 04 '15 at 08:35
  • And all the ProcMon calls to ZedGraph.dll are using the `..Source-1\Sakura II\lib\ZedGraph.dll` ? No other calls to a different directory? And there isn't a **File Not Found** in the ProcMon log? – Jeremy Thompson Feb 04 '15 at 08:50
  • Yes, there is one but it looks in resharper directory (?!) – Thomas Ayoub Feb 04 '15 at 08:51
  • Post it, I have a feeling its a red-herring but could be the root cause – Jeremy Thompson Feb 04 '15 at 08:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/70198/discussion-between-thomas-and-jeremy-thompson). – Thomas Ayoub Feb 04 '15 at 08:53
0

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

How about the assembly/DLL where Sakura.UI.Graphing.LineGraphControl is defined?

Shadocko
  • 1,186
  • 9
  • 27