C#编译器在没有错误消息的情况下崩溃

时间:2013-12-20 15:41:33

标签: c# .net

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

上面的代码会使编译器在构建时崩溃。 我希望编译器停止使用有意义的错误消息,而不是尝试编译代码。 它可能是编译器中的错误吗?如果没有,我该如何解决这个错误?

2 个答案:

答案 0 :(得分:6)

这不是编译器中的错误;编译器给出了正确的错误信息 相反,这是Visual Studio编辑器语言服务中的一个错误,导致Visual Studio崩溃。

但是,您的代码无论如何都是非法的; __arglist(...)表达式只能用于调用带__arglist的函数。

答案 1 :(得分:4)

看起来像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)