Ticket Q535267
Visible to All Users
Duplicate

problem using SetIdPrefix to resolve name collisions in views

created 11 years ago

Application is XAF Winforms only.
In regards to https://www.devexpress.com/Support/Center/Question/Details/S19870

I have modified my code as described in the description. Specifically:

* In my Windows Forms Application Project, I have added calls to SetIdPrefix in my Program.cs file for each class that has a conflict, for example:
ModelNodesGeneratorSettings.SetIdPrefix(typeof(Sil.Png.PartTracker.Wizards.Batch.AuthorizeInvalidPurchaseOrder.Finish), "AuthorizeInvalidPurchaseOrder.Finish");
ModelNodesGeneratorSettings.SetIdPrefix(typeof(Sil.Png.PartTracker.Wizards.Batch.RequestInvalidPurchaseOrder.Finish), "RequestInvalidPurchaseOrder.Finish");

* I have edited my xafml files to fix the differences that references all of the above classes, for example:
<DetailView Id="AuthorizeInvalidPurchaseOrder.Finish_DetailView" FreezeLayout="True">
These xafml files are in my Module Project and my Windows Forms Module Project.

It works fine when I execute the program. I have only verified that it starts up, I have not visited all the views involved. But that seems sufficient because I was getting startup errors until I added the calls to SetPrefixId.

The problem is that I cannot use the Update Model nor can I edit the model without getting an error. The error text is:
Error:
There is already node with Id 'Finish_ListView'. The node: Application/Views/Finish_ListView.
Update failed

When I attempt to edit the model I get the above internal error message with a warning that I should not edit the model. Then the model editor opens and I can browse around. Drilling down into the views I see this:

Quite clearly, the SetPrefixId calls have had no effect on the design-time environment. That makes a lot of sense to me since they are in different assemblies.

On a hunch, I added the same set of calls to SetIdPrefix into my Module Project, Module.cs, in the constructor just before the call to InitializeComponent(). That changed the behavior! I no longer have any errors on Update Model or opening the model editor. However some of my nodes are now in the unusablenodes.xml file. I suspect that is a different issue for me to resolve (we have had a lot of turmoil on our class hierarchy so it wouldn't surprise me). I'll investigate the unusable nodes tomorrow and I'll take this as a successful trial. I conclude somewhere in my module I need to call SetIdPrefix.

Now I don't want to just hack that in there without your input. Given all of this, what do I need to do to have the design-time environment and the actual program work correctly?
Where are we really supposed to call SetIdPrefix? Does it need to be in multiple places (modules?)?

Thank you,
Steve

Comments (2)

    oops, I had pasted a screen snip in the editor but it didn't make it into the posting. I already closed snip and have changed my code so I'll just describe it. The snip showed the Views section of the model. It had the AuthorizeInvalidPurchaseOrder namespace with a Finish_DetailView, it did not use AuthorizeInvalidPurchaseOrder.Finish like my call to SetIdPrefix requested. The namespace RequestInvalidPurchaseOrder had views defined up to just before the Finish class would have been encountered showing that the error came while attempting to process that class.

      I have reviewed and resolve all of the unusable nodes. They were all cost by name changes unrelated to this issue. Therefore, it appears that I can replicate the calls to SetIdPrefix in every module that has any of the views with conflicting names. This seems to make the Update Model, model editor and application startup all processed the model in the same way. I've not extensively tested the application at this point to prove that everything works fine. While this seems to be a functional solution it is obviously not desirable. I will wait for your response before going further.

      Answers approved by DevExpress Support

      created 11 years ago (modified 11 years ago)

      Hello Steve,
      Specifying a prefix at application startup is sufficient for running the app. If you also need this functionality for design time, then you can set the prefix from within the static or instance constructor of your platform-agnostic module.
      Also please note that your View identifiers must be without a namespace. For instance, it should be set to Finish_DetailView in the XAFML files instead of AuthorizeInvalidPurchaseOrder.Finish_DetailView, unless you configured the "AuthorizeInvalidPurchaseOrder.Finish" prefix for your Finish type.
      The cause of your unusable nodes is most likely in using long identifiers. Yon can easily confirm these by checking these unusable files.
      To fix this, you can either correct your XAFML files to use short identifiers instead or set prefixes (it's a bit longer).
      I hope this helps.

        Show previous comments (4)

          I have tried to see if this will allow the mapping of Multiple Databases with the same structure and naming to be used in XAF.
          Combining this with args.ObjectSpaceProviders.Add(New XPObjectSpaceProvider( _
             ConfigurationManager.ConnectionStrings("ConnectionStringXXX").ConnectionString, Nothing))
                  args.ObjectSpaceProviders.Add(New XPObjectSpaceProvider( _
             ConfigurationManager.ConnectionStrings("ConnectionStringXXX").ConnectionString, Nothing))
          But all I get is that the 2 are mapped to the same table. I still have no idea where to setIdPrefix. Where is the Static constructor so that this will work in both UI design & App.
          I'm lost.

            Ken,
            I currently have identical calls to SetIdPrefix in three locations. I also have a task on my list to refactor this so I don't have the duplicate code. But I found that the calls need to be made in these three locations for these three reasons. Note that my solution is Windows Forms only, if you also use the ASP .Net platform you may need additional calls.
            myapp.Module, in the constructor of my subclass of ModuleBase -- this module is where the business objects with conflicting names are defined. If the calls are not here the design-time environment doesn't work right.
            myapp.Module.Win, in the constructor of my subclass of ModuleBase -- in this module, the business objects with conflicting names are visible so the calls are needed. If the calls are not here the design-time environment doesn't work right.
            myapp.Win, in the Main method-- This is where DevExpress said to put them in https://www.devexpress.com/Support/Center/Question/Details/S19870 . If the calls are not here then the application fails at startup. I have not tried removing these calls since I added the other two sets of calls, it may be that these are no longer needed.
            As for addressing your idea about using these in relation to multiple databases, I have no input for you. I suggest you create a separate question to get the best service from DevExpress.
            Steve
            P.S. I suggest you go to https://www.devexpress.com/Support/Center/p/Q536483.aspx and click the up-triangle by the number to vote for documentation on this mess.

            Dennis Garavsky (DevExpress) 11 years ago

              @Steve: Thanks for your comments.
              @Ken: Please create a separate ticket and attach your problematic project there, so that we could see what you tried and what did not work for you. Thanks.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.