Сбой компилятора С# без сообщения об ошибке - программирование

Сбой компилятора С# без сообщения об ошибке

var xrr = __arglist(Convert.ToUInt32(1), 
                    Convert.ToUInt32(2), 
                    Convert.ToUInt32(3));

Приведенный выше код может привести к сбою компилятора при сборке. Я ожидаю, что компилятор остановится со значимым сообщением об ошибке, вместо того, чтобы пытаться скомпилировать код. Может быть, это ошибка в компиляторе? Если нет, как я могу решить эту ошибку?

4b9b3361

Ответ 1

Это не ошибка в компиляторе; компилятор дает правильное сообщение об ошибке.
Вместо этого это ошибка в языковой службе редактора Visual Studio, что приводит к сбою Visual Studio.

Однако ваш код является незаконным; __arglist(...) выражения могут использоваться только для вызова функции, которая принимает __arglist.

Ответ 2

Похож на проблему с Visual Studio, а не с компилятором:

VS2010

System.AccessViolationException

Попытка чтения или записи защищенной памяти. Это часто свидетельствует о том, что другая память повреждена.

Источник

Microsoft.VisualStudio.CSharp.Services.Language

Трассировка стека

   at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.CompilerIDEInterop.Compilation_CompileMethod(Handle handle, Handle baseNodeOwner, IntPtr baseNodePtr, Handle& treeHandle)
   at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.CompileMethod(ParseTreeNode node)
   at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.CompileMethod(MethodBaseNode method)
   at Microsoft.RestrictedUsage.CSharp.Semantics.SemanticParseTreeVisitor.<>c__DisplayClassc.<DispatchMethodBody>b__a()
   at Microsoft.RestrictedUsage.CSharp.Extensions.ExpressionTreeFinder.get_ExpressionTree()
   at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.FindExpressionTree(Compilation compilation, SourceFile sourceFile, ParseTreeNode leafNode)
   at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetUniqueLocals(CSharpMemberReference member, ParseTreeNode node, SourceLocation loc, Dictionary`2 dictionary)
   at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetUniqueLocals(Dictionary`2 locals)
   at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetMemberChildren()
   at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.InitializeItemCollection()
   at Microsoft.VisualStudio.Labs.ItemsSource`2.InitializeItems()
   at Microsoft.VisualStudio.Labs.ItemsSource`2.get_Items()
   at Microsoft.VisualStudio.Labs.AggregateItemsSource.InitializeItemCollection()
   at Microsoft.VisualStudio.Labs.ItemsSource`2.InitializeItems()
   at Microsoft.VisualStudio.Labs.ItemsSource`2.get_Items()
   at Microsoft.VisualStudio.Labs.BrowserNavigationEntry.GetTree(String relationship, Func`2 treeActivator)
   at Microsoft.VisualStudio.Labs.Browser.OnSelectedRelationshipChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Microsoft.VisualStudio.Labs.Browser.OnCurrentNavigationEntryChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value)
   at Microsoft.VisualStudio.Labs.Browser.NavigateTo(Object root, IRelationship relationship)
   at Microsoft.VisualStudio.Labs.Browser.NavigateTo(Object root)
   at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.RenderSelectionPopup(Object item, PopupType popupType)
   at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.PotentiallyShowCSharpPopup(CSharpTextSelection activeSelection, PopupType popupType)
   at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.textView_MouseHover(Object sender, MouseHoverEventArgs e)
   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents()
   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.OnHoverTimer(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)