Hello,
I am using XamDiagram in a small AutoCad addin. Somehow XamDiagram is crashing the whole program, including AutoCad.
when looking at the exception:
System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'Infragistics.Controls.Charts.XamDiagram' that matches the specified binding constraints threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb' or one of its dependencies. The system cannot find the file specified. [REST OF EXCEPTION AT THE BOTTOM OF THE QUESTION]
It indicates that InfragisticsWPF4.DragDrop.v17.2 or one of it's dependencies could not be loaded.In my project I have referenced and included the InfragisticsWPF4.DragDrop.v17.2.dll
Beside The XamDiagram I also use XamTreeGrid, and there is no problems with that one.
When trying to reproduce this issue in a WPF app, I get a similar Exception in the debug mode, but the app can be continued.
System.IO.FileNotFoundException: 'Could not load file or assembly 'InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2, Version=17.2.20172.2029, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' or one of its dependencies. The system cannot find the file specified.'
StackTrace:
" at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)"
Fusionlog:
"=== Pre-bind state information ===\r\nLOG: DisplayName = InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2, Version=17.2.20172.2029, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Users/nawed/Desktop/WorkSpaceVS/TestApplication/WpfXamDiagramTest64x/bin/Release/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\\Users\\nawed\\Desktop\\WorkSpaceVS\\TestApplication\\WpfXamDiagramTest64x\\bin\\Release\\WpfXamDiagramTest64x.exe.Config\r\nLOG: Using host configuration file: \r\nLOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config.\r\nLOG: Post-policy reference: InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2, Version=17.2.20172.2029, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb\r\nLOG: Attempting download of new URL file:///C:/Users/nawed/Desktop/WorkSpaceVS/TestApplication/WpfXamDiagramTest64x/bin/Release/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2.DLL.\r\nLOG: Attempting download of new URL file:///C:/Users/nawed/Desktop/WorkSpaceVS/TestApplication/WpfXamDiagramTest64x/bin/Release/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2.DLL.\r\nLOG: Attempting download of new URL file:///C:/Users/nawed/Desktop/WorkSpaceVS/TestApplication/WpfXamDiagramTest64x/bin/Release/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2.EXE.\r\nLOG: Attempting download of new URL file:///C:/Users/nawed/Desktop/WorkSpaceVS/TestApplication/WpfXamDiagramTest64x/bin/Release/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2/InfragisticsWPF4.Controls.Charts.XamDiagram.v17.2.Aero2.EXE.\r\n"
So question is if there are some dependecies that we are missing ?
If not how to avoid this exception ?
[EXCEPTION DETAILS]
Application does not support just-in-time (JIT)
debugging. See the end of this message for details.
************** Exception Text **************
System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'Infragistics.Controls.Charts.XamDiagram' that matches the specified binding constraints threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Windows.Baml2006.Baml2006SchemaContext.ResolveAssembly(BamlAssembly bamlAssembly)
at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlTypeToType(BamlType bamlType)
at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(BamlType bamlType, Int16 typeId)
at System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
at System.Windows.Baml2006.Baml2006SchemaContext.GetProperty(Int16 propertyId, XamlType parentType)
at System.Windows.Baml2006.Baml2006Reader.Process_PropertyComplexStart()
at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
at System.Windows.Baml2006.Baml2006Reader.ReadObject(KeyRecord record)
at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
at System.Windows.SystemResources.LookupResourceInDictionary(ResourceDictionary dictionary, Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
at System.Windows.SystemResources.FindDictionaryResource(Object key, Type typeKey, ResourceKey resourceKey, Boolean isTraceEnabled, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
at System.Windows.FrameworkElement.UpdateThemeStyleProperty()
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Infragistics.Controls.Charts.XamDiagram..ctor()
at System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.CallCtorDelegate(XamlTypeInvoker type)
at System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.CreateInstance(XamlTypeInvoker type)
at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)
--- End of inner exception stack trace ---
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at CBTools15.Views.PS2Acis.InitializeComponent()
at CBTools15.Views.PS2Acis..ctor(Object objCaller)
at CBTools15.AcadCommands.PS2ACIS()
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
Since the XamTreeGrid works my expectation is that you do have all of the dependent assemblies and maybe the DragDrop assembly that you have referenced is a version that doesn't match the other assemblies so the one for the correct version may not be found. I recommend verifying that all of your references are the same.
You can double check the dependent assemblies in the Ultimate UI for WPF Assemblies list.
Let me know if you have any questions.
Hi Alan,
Thanks for the fast reply.
I checked the versions of the assemblies, and it looks like they all are the same version. I only have one version installed on my computer:
Your welcome, if you do have further questions feel free to follow up.
Thanks for the replies and for your time.
I now know enough to handle this.
There isn't anything in our assemblies that control where they look for dependencies and that is all done by the .NET Framework. By default they will be looking in the folder of the running application when they are loaded and the GAC.
By any chance are you manually loading the XamTreeGrid or handling AppDomain.AssemblyResolve to load the assembly from an alternative location?
If not the AppDomain.AssemblyResolve might provide an alternative to putting the assemblies in the directory with the AutoCAD executable or the GAC. You might also find How to: Load Assemblies into an Application Domain interesting.
The fuslogvw.exe helped clearing things up!
and looking into the details:
*** Assembly Binder Log Entry (15-03-2018 @ 10:09:22) *** The operation failed.Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dllRunning under executable C:\Program Files\Autodesk\AutoCAD 2015\acad.exe--- A detailed error log follows. === Pre-bind state information ===LOG: DisplayName = InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb (Partial)WRN: Partial binding information was supplied for an assembly:WRN: Assembly Name: InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb | Domain ID: 1WRN: A partial bind occurs when only part of the assembly display name is provided.WRN: This might result in the binder loading an incorrect assembly.WRN: It is recommended to provide a fully specified textual identity for the assembly,WRN: that consists of the simple name, version, culture, and public key token.WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.LOG: Appbase = file:///C:/Program Files/Autodesk/AutoCAD 2015/LOG: Initial PrivatePath = NULLLOG: Dynamic Base = NULLLOG: Cache Base = NULLLOG: AppName = acad.exeCalling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.===LOG: This bind starts in default load context.LOG: Using application configuration file: C:\Program Files\Autodesk\AutoCAD 2015\acad.exe.ConfigLOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2.DLL.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2/InfragisticsWPF4.DragDrop.v17.2.DLL.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2.EXE.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2/InfragisticsWPF4.DragDrop.v17.2.EXE.LOG: All probing URLs attempted and failed. *** Assembly Binder Log Entry (15-03-2018 @ 10:09:22) *** The operation failed.Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dllRunning under executable C:\Program Files\Autodesk\AutoCAD 2015\acad.exe--- A detailed error log follows. === Pre-bind state information ===LOG: DisplayName = InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb (Partial)WRN: Partial binding information was supplied for an assembly:WRN: Assembly Name: InfragisticsWPF4.DragDrop.v17.2, PublicKeyToken=7dd5c3163f2cd0cb | Domain ID: 1WRN: A partial bind occurs when only part of the assembly display name is provided.WRN: This might result in the binder loading an incorrect assembly.WRN: It is recommended to provide a fully specified textual identity for the assembly,WRN: that consists of the simple name, version, culture, and public key token.WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.LOG: Appbase = file:///C:/Program Files/Autodesk/AutoCAD 2015/LOG: Initial PrivatePath = NULLLOG: Dynamic Base = NULLLOG: Cache Base = NULLLOG: AppName = acad.exeCalling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.===LOG: This bind starts in default load context.LOG: Using application configuration file: C:\Program Files\Autodesk\AutoCAD 2015\acad.exe.ConfigLOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2.DLL.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2/InfragisticsWPF4.DragDrop.v17.2.DLL.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2.EXE.LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/AutoCAD 2015/InfragisticsWPF4.DragDrop.v17.2/InfragisticsWPF4.DragDrop.v17.2.EXE.LOG: All probing URLs attempted and failed.
Somehow XamDiagram is looking in the AutoCad folder for it's depencies.And for testing purposes I copied the DragDrop DLL to the autocad folder and it started to complain about XamSlider DLL, at the end I had to copy all the dependencies for XamDiagram to the AutoCad folder before it worked.
Seems strange because the XamTreeGrid knows where to look for it dependecies while XamDiagram doesn't.
Does the WPF app actually crash or do you just break on a first chance exception? If it crashes, then that might be an issue we need to address though from the screen shot it appears that you were catching a first chance exception and my expectation is the WPF app would run without issue.
Regarding testing with a different version, I don't believe that is going to have an impact on behavior or a least not directly since for some reason the .NET Framework is failing to load the DragDrop assembly. Does it make a difference or work around the behavior if the DragDrop assembly is in the GAC (which it should be if you installed the wpf toolset on your machine)?
It also appears that the FusionLog output provided above is form the WPF test and it would be better to have the output from when the assembly is being loaded into AutoCAD. What is in the logs if you use the Fuslogvw.exe (Assembly Binding Log Viewer) to get more details on what is happening when the assembly is being loaded in the AutoCAD extension?