Cannot locate resource 'folder/SomeView.xaml'

Cannot locate resource 'folder/SomeView.xaml'

tamas.deri
Advocate Advocate
701 Views
4 Replies
Message 1 of 5

Cannot locate resource 'folder/SomeView.xaml'

tamas.deri
Advocate
Advocate

I'm facing a very frustrating issue with one of our addins. It is only happening on a single specific computer, only with Revit 2023 & 2024. All of the WPF windows throw an exception in the View's InitalizeComponent() method because they cannot locate the xaml resource. The dockable panes are working fine. In Revit 2020-2022 everything is fine on this pc, and have no issues on any other computers. If I make a simple minimal addin with a single wpf window in a separate project that is also working fine on that pc, and all the other third party addins that are using wpf are working fine.

I also checked our built assembly with .NET Reflector and I have all the .baml resources with their correct path under Addin.g.resources, and the generater InitalizeComponent() methods have the correct URI.
So in summary, I only have this issue on a single computer, in R2023, R2024 in a single addin, and only with wpf windows. Did anyone face a similar situation? Right now we have no idea, we are at the verge of reinstalling the whole OS.

0 Likes
702 Views
4 Replies
Replies (4)
Message 2 of 5

ricaun
Advisor
Advisor

I had a similar problem one time, in the end, was something in the xaml that was not properly initialized and made the InitalizeComponent throw some exception.

 

As you describe if only fails in one computer with version R2023 and R2024 and the rest works fine, it possibly is some other plugin interfering with yours.

 

I don't know how complex is your WPF and what dependencies you are trying to use in there. A good way to test would be to create an empty WPF a see if works.

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 3 of 5

tamas.deri
Advocate
Advocate

Unfortunately it is not a single xaml, but ALL the WPF windows in this specific addin behave this way, even implemented a very minimal new window for testing purposes, that throws the same exception.

 

This specific addin also has a bunch dependencies, it is kind of a legacy tool, that is quite difficult to maintain, it is not a pleasure to figure out this issue.

 

I'll try to test it in isolation using journal playback to only load this single third party addin, and see how it behaves. Maybe it has some conflict with other installed addins.

0 Likes
Message 4 of 5

tamas.deri
Advocate
Advocate

Okay, we are getting somewhere. In isolated context the addin works fine, so must be conflicting with some other addins. It has a lot of dependecies like Extended WPF Toolkit, Serilog WPF packages and so on. Any idea how to track down the conflicting addin?

0 Likes
Message 5 of 5

ricaun
Advisor
Advisor

That's strange an empty WPF fail...

 

You could try to check where all the references of your plugin are coming from.

 

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Linq;
using System.Reflection;
using System.Windows;

namespace RevitAddin.Forum.Revit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class CommandAssemblies : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
        {
            UIApplication uiapp = commandData.Application;

            var referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies().OrderBy(e => e.Name);
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            var text = string.Empty;
            foreach (var assemblyName in referencedAssemblies)
            {
                var similarAssemblies = assemblies.Where(e => assemblyName.Name == e.GetName().Name);
                foreach (var similarAssembly in similarAssemblies)
                {
                    var location = string.Empty;
                    try
                    {
                        location = similarAssembly.Location;
                    }
                    catch { }

                    Console.WriteLine($"{similarAssembly} \t {location}");

                    text += $"{similarAssembly} \t {location}\n";
                }
            };

            Clipboard.SetText(text);

            return Result.Succeeded;
        }
    }
}

 

This gonna copy all the assembly references and each location to the Clipboard.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes