Ticket S30927
Visible to All Users

How to avoid the "Dictionary already contains class info" exception when opening Application, Module or Model Editor designers with projects having multiple dependent class libraries

created 16 years ago
Comments (1)
DevExpress Support Team 16 years ago

    Hello,
    Currently, XAF doesn't support this projects structure: [ObjectsLib + CommonModule + WinFormsModule + WinFormsApplication]
    And, this structure is not supported by VisualStudio out of the box: an old assembly could be loaded after rebuilding an entire solution ( see also: B32244 ).
    Thanks,
    Dan

    Answers approved by DevExpress Support

    created 16 years ago (modified 5 years ago)

    We suggest you ensure that projects in your XAF solution use project-to-project references instead of file assembly references. Microsoft recommends this as the best way to manage references in a project: https://docs.microsoft.com/en-us/visualstudio/ide/managing-references-in-a-project?view=vs-2019#project-to-project-references. Our Model Editor requires project-to-project references to collect accurate dependency information. If projects inside your XAF solution are added as file references, it may not only increase maintenance costs, but also cause "Dictionary already contains ClassInfo. Possible reason: the assembly has been loaded twice" errors in the Model Editor.

    We avoided this behavior in the new Model Editor for .NET Core and .NET Standard projects (v20.1+), which uses a different architecture and out-of-Visual Studio process. For more information, please review the following help topics:


    Hi guys,
    This error is a result of a bug in Visual Studio: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=379324. I am afraid we cannot overcome it on our side.
    EDIT: Microsoft said that they couldn't fix this problem of Visual Studio. So, I have posted ( http://social.msdn.microsoft.com/Forums/en-US/csharpide/thread/b7ee8b92-335d-4118-b609-eb7825c7d1a4 ) on their forum to see a feedback from other users and to gather votes or find a workaround for this issue.

    Currently, you can use the following solutions:

    1. Reopen the Visual Studio when the "Dictionary already contains class info" error occurs;
    2. Simplify the Visual Studio solution's hierarchy by referencing an output assembly instead of referencing a project.
      For instance, if the error mentioned the <YourSolutionName>.Module assembly, then you can reference its output assembly (<YourSolutionName>.Module.dll) instead of having its source added into your Visual Studio solution.
    3. Use a standalone Model Editor tool (%ProgramFiles%\DevExpress 15.2\Components\Tools\eXpressAppFramework\Model Editor"
      Show previous comments (1)

        As I understand, no progress here after 8 years and Visual Studio 2015?

        Dennis Garavsky (DevExpress) 9 years ago

          @Ilja: To process your recent post more efficiently, I created a separate ticket on your behalf: T321982: Questions regarding S30927. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

          Dennis Garavsky (DevExpress) 5 years ago

            If you happen to reproduce “assembly loaded twice” and related errors with your project, please install XAF v19.2.3+.

            To enable tracing for your XAF solution, do the following:

            1. Edit your .sln file in Notepad or your favorite text editor.
            2. Find the GlobalSection(ExtensibilityGlobals) = postSolution section. If it does not exist, add the following code before the EndGlobal element:
            Code
            GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection
            1. Insert EnableDesignTimeTracing = true into the GlobalSection(ExtensibilityGlobals) = postSolution section.
            Code
            GlobalSection(ExtensibilityGlobals) = postSolution EnableDesignTimeTracing = true EndGlobalSection

            Logs must be saved into the eXpressAppFramework.log file inside the solution folder - please send them to us. Disable tracing once you finish collecting the logs, because these logs slow down Visual Studio.

            Thank you very much for your help in advance!

            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.