Help! Several machines, single GUI...

Post Reply
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

Help! Several machines, single GUI...

Post by IXix »

I have project configurations to build different versions of my patchbay machine with varying numbers of parameters: IX PatchBay 3.0 12x4.dll, IX PatchBay 3.0 16x8.dll and IX PatchBay 3.0 24x2.dll. It works great for the machine dlls but I can't figure out how to automatically build the relevant GUI dll with the correct name. There doesn't seem to be a way to change the Assembly Name property by configuration. :(

I tried using the GUI properties post-build event to copy the dll to a new file with the right name but only one of them works. The other two give me this this error...

Image

Any idea how I can make this work? I'll be adding several machine variations so I don't want to have to create a GUI project for each of them when it's exactly the same code. What does the error mean and is there any way I can build the GUI.dll conditionally by via the project configuration to fix it? Or is there any way to force the various machine dlls to use a single core GUI.dll?

Please help! I'm using VS2010.
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

Re: Help! Several machines, single GUI...

Post by IXix »

Hmmm, well in the light of a new day a batch rebuild seems to have fixed it. All three versions work properly now. Maybe it was because I did a batch build last night instead of a batch rebuild and something wasn't changed that should have been. I'll have to be wary of that in future but for now... :dance:
User avatar
thOke
Posts: 343
Joined: Thu Nov 24, 2011 7:14 am

Re: Help! Several machines, single GUI...

Post by thOke »

thumbs_up_smiley.gif
thumbs_up_smiley.gif (762 Bytes) Viewed 8301 times
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

Re: Help! Several machines, single GUI...

Post by IXix »

Nope, it's still there. :(

I copied "IX PatchBay 3.0.GUI.dll" to three new files named according to the number of inputs and outputs, ie. "IX PatchBay 3.0 12x4.GUI.dll"

At first it seems that everything works fine. I can create instances of the various machines and the GUI opens fine but at some point I'll create an instance and opening the parameter window throws the exception:
Message=The component 'GUI.PatchbayGUI' does not have a resource identified by the URI '/IX Patchbay 3.0.GUI;component/ix%20patchbay%203.0.gui..xaml'.
Source=PresentationFramework
StackTrace:
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at GUI.PatchbayGUI.InitializeComponent()
at GUI.PatchbayGUI..ctor()
at GUI.MachineGUIFactory.CreateGUI(IMachineGUIHost host)
It looks like loading the same dll with a different name causes a resource id conflict with the previously loaded dlls. The exception happens in this auto-generated function...

Code: Select all

        /// <summary>
        /// InitializeComponent
        /// </summary>
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
        public void InitializeComponent() {
            if (_contentLoaded) {
                return;
            }
            _contentLoaded = true;
            System.Uri resourceLocater = new System.Uri("/IX Patchbay 3.0.GUI;component/ix%20patchbay%203.0.gui..xaml", System.UriKind.Relative); // DO I NEED TO GENERATE THIS STRING AT RUNTIME?
            
            #line 1 "..\..\IX Patchbay 3.0.GUI..xaml"
            System.Windows.Application.LoadComponent(this, resourceLocater); // EXCEPTION THROWN HERE
            
            #line default
            #line hidden
        }
I found a related thread on stackoverflow but it's a slightly different problem and I don't understand it well enough to adapt the workaround for my situation.

A professional opinion could save me hours of stab-in-the-dark coding. Could I sidestep the issue by loading the xaml from a file instead of embedding it as a resource?

HELP!
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

Re: Help! Several machines, single GUI...

Post by IXix »

SOLVED!

I put the actual gui code into a separate dll so all that's in the GUI.dll is the IMachineGUIFactory implementation. All flavours of the patchbay machine reference the same core dll so it only loads once and there are no resource problems.

:dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance:
User avatar
AndersBrontosaurus
Posts: 516
Joined: Mon Feb 25, 2013 9:31 am
Location: Fellingsbro

Re: Help! Several machines, single GUI...

Post by AndersBrontosaurus »

:-)
Post Reply