Visual Studio freezes when adding new XSharp Class

This forum is meant for questions and discussions about the X# language and tools
Post Reply
JoeD
Posts: 10
Joined: Wed Apr 09, 2025 12:59 pm
Location: Deutschland

Visual Studio freezes when adding new XSharp Class

Post by JoeD »

Hi everyone,

I'm fairly new to XSharp and recently started working on a project that uses it.

Whenever I try to add a new XSharp class to a recently created XSharp project, Visual Studio often becomes unresponsive and displays a "Visual Studio is busy" message. I usually have to force close Visual Studio via Task Manager. When I reopen the solution and try to add the class again, I get a message saying that the file already exists and asking if I want to replace it. After confirming, the file is created as expected, and I can continue working—until I try to add the next class, and the issue repeats.

This is quite frustrating, and I hope someone can help me resolve it.

Below is a part of the stack trace that appears during the issue.

Best Regards
Johannes
[Managed to Native Transition]
> mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) Line 529 C#
Microsoft.Build.dll!Microsoft.Build.BackEnd.RequestBuilder.WaitWithBuilderThreadStart(System.Threading.WaitHandle[] handles, bool recursive, Microsoft.Build.Execution.LegacyThreadingData threadingData, int submissionId) Unknown
Microsoft.Build.dll!Microsoft.Build.Execution.BuildSubmission.Execute() Unknown
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ProjectNode.DoMSBuildSubmission(Microsoft.VisualStudio.Project.BuildKind buildKind, string target, ref Microsoft.Build.Execution.ProjectInstance projectInstance, Microsoft.VisualStudio.Project.MSBuildCoda uiThreadCallback) Line 3660 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.AssemblyReferenceNode.BuildInstance(Microsoft.VisualStudio.Project.ProjectNode projectNode, Microsoft.Build.Execution.ProjectInstance instance, string target, out Microsoft.Build.Execution.BuildSubmission submission) Line 440 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.AssemblyReferenceNode.ResolveAssemblyReference() Line 497 C#
XSharp.Project2022.dll!XSharp.Project.XSharpAssemblyReferenceNode.ResolveAssemblyReference() Line 153 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.AssemblyReferenceNode.CreateFromAssemblyName(System.Reflection.AssemblyName name) Line 254 C#
XSharp.Project2022.dll!XSharp.Project.XSharpReferenceContainerNode.CreateAssemblyReferenceNode(string fileName) Line 197 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ReferenceContainerNode.CreateFileComponent(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string wrapperTool) Line 536 C#
XSharp.Project2022.dll!XSharp.Project.XSharpReferenceContainerNode.CreateFileComponent(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string _wrapperTool) Line 174 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ReferenceContainerNode.CreateReferenceNode(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string wrapperTool) Line 456 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ReferenceContainerNode.AddReferenceFromSelectorData(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string wrapperTool) Line 385 C#
XSharp.Project2022.dll!XSharp.Project.XSharpReferenceContainerNode.AddReferenceFromSelectorData(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string wrapperTool) Line 47 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.Automation.OAReferences.Add(string bstrPath) Line 99 C#
Microsoft.VisualStudio.TemplateWizard.dll!Microsoft.VisualStudio.TemplateWizard.Wizard.AddReferences(EnvDTE.Project project, System.Xml.XmlNodeList refAssemblies) Unknown
Microsoft.VisualStudio.TemplateWizard.dll!Microsoft.VisualStudio.TemplateWizard.Wizard.AddProjectReferences(EnvDTE.Project project, System.Xml.XmlNode referencesNode) Unknown
Microsoft.VisualStudio.TemplateWizard.dll!Microsoft.VisualStudio.TemplateWizard.Wizard.Execute(object application, System.IntPtr hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref EnvDTE.wizardResult retval) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ProjectNode.RunWizard(Microsoft.VisualStudio.Project.HierarchyNode parentNode, string itemName, string wizardToRun, System.IntPtr dlgOwner) Line 2120 C#
XSharp.Project2022.dll!XSharp.Project.XSharpProjectNode.RunWizard(Microsoft.VisualStudio.Project.HierarchyNode parentNode, string itemName, string wizardToRun, System.IntPtr dlgOwner) Line 830 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ProjectNode.AddItemWithSpecific(uint itemIdLoc, Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, System.IntPtr dlgOwner, uint editorFlags, ref System.Guid editorType, string physicalView, ref System.Guid logicalView, Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[] result, bool bTrackChanges) Line 5540 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ProjectNode.AddItemWithSpecific(uint itemIdLoc, Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, System.IntPtr dlgOwner, uint editorFlags, ref System.Guid editorType, string physicalView, ref System.Guid logicalView, Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[] result) Line 5489 C#
XSharp.ProjectBase2022.dll!Microsoft.VisualStudio.Project.ProjectNode.AddItem(uint itemIdLoc, Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, System.IntPtr dlgOwner, Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[] result) Line 5460 C#
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Visual Studio freezes when adding new XSharp Class

Post by Jamal »

Johannes,

It would help the X# team if you provide the Visual Studio version and X# version.

It seems that there is a deadlock deep in the X# system when adding a reference to the project (AddReferenceFromSelectorData → CreateReferenceNode → ResolveAssemblyReference) which triggers a build submission (DoMSBuildSubmission) to resolve the assembly
The thread is stuck waiting in System.Threading.WaitHandle.WaitAny within MSBuild and this suggests the MSBuild process is either deadlocked or stalled, blocking the UI thread.

I don't get the same issue. I am running the VS 2022 community edition Version 17.14.7 As an Administrator.
XSharp Cahors 2.21.0.5 - Public version

Jamal
JoeD
Posts: 10
Joined: Wed Apr 09, 2025 12:59 pm
Location: Deutschland

Re: Visual Studio freezes when adding new XSharp Class

Post by JoeD »

Hi Jamal,

I'm using Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.14.4 and XSharp Cahors 2.23.0.2.

I'm not sure why my System would behave like this.
I already disabled all non standard Extensions.

Anything else I could try?

Best regards
Johannes
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Visual Studio freezes when adding new XSharp Class

Post by Jamal »

Can you try to uninstall and reinstall X#?

HTH,
Jamal
JoeD
Posts: 10
Joined: Wed Apr 09, 2025 12:59 pm
Location: Deutschland

Re: Visual Studio freezes when adding new XSharp Class

Post by JoeD »

Hi Jamal,

Sorry for the late reply — I was tied up with other tasks.

I uninstalled version 2.23.0.2 and installed the newly released version 2.24.0.1. Unfortunately, the issue remains the same.

The solution containing the problematic project includes many other projects. When I try the same in a newly created solution with just a single project, I can’t reproduce the problem.

Do you have any idea what could be causing the issue in the larger solution?

Update:
I also tried loading just the project where I want to add the new class. That works without freezing. So the issue seems to be related to the full solution.

Thanks,
Johannes
Juraj
Posts: 164
Joined: Mon Jan 09, 2017 7:00 am

Re: Visual Studio freezes when adding new XSharp Class

Post by Juraj »

Hi All,

VS22 freezes for me after changing the xaml file. Even if I create a new project and edit the xaml file through the designer or manually, after a while VS freezes and after restarting VS freezes after every xaml edit.

Juraj
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Visual Studio freezes when adding new XSharp Class

Post by Jamal »

Hi Johannes,

It is either the VS cannot handle large solutions or there is an issue with one the projects.
I suggest you start adding the projects one by one then test to try to see at which project things break.

I think X# team should jump in this discussion; they may have a deeper knowledge.

Jamal
ic2
Posts: 1956
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: Visual Studio freezes when adding new XSharp Class

Post by ic2 »

Hello Johannes,

I posted a reply which seems to have been lost. Here it is again. I installed VS2022 to enable some .Net8 stuff which Syncfusion said to be necessary. In one of my solutions, the Design window of a WPF XAML screen remained empty except a header while the same solution worked perfectly in VS2019. Even pasting a XAML window working in another VS2022 solution did not show that window.
As the Syncfusion based solution proved to work perfectly in VS2019 as well, I saw no advantages of continuing with VS2022 for now. But I can imagine that rebuilding the solution from scratch in VS2022 and gradually pasting content would help. Probably also for you.

Dick
Last edited by ic2 on Tue Jul 22, 2025 8:22 am, edited 1 time in total.
JoeD
Posts: 10
Joined: Wed Apr 09, 2025 12:59 pm
Location: Deutschland

Re: Visual Studio freezes when adding new XSharp Class

Post by JoeD »

Thank you for your replies.
Next time, I’ll try to modularize the solution, although I’m not sure how easy that will be.

I’m still holding out some hope for X# 3, especially with the possibility of using SDK-style projects and the improved reference handling that comes with it.
Post Reply