question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to run dotnet core application on Mac using dotnet command, but works under vscode

See original GitHub issue

@danwalmsley commented on Tue Jul 11 2017

Basically I have an application written for netcoreapp2.0

It runs perfectly via vscode debugger with setting

"console": "internalConsole" (I mention this as it may be a clue to what is happening)

If I tell vscode to use external console or…

If I run it through the terminal on mac and do dotnet ./myapp.dll

I starts to load and crashes with

could not load file or assembly System.Text.RegularExpressions, Version=4.0.0.0

How can it be the case it works under vscode terminal but not bash? How can I get more verbose output that could help you guys diagnose the issue?


@gkhanna79 commented on Wed Jul 12 2017

@steveharter should be able to help out here.


@danwalmsley commented on Fri Jul 14 2017

Thanks! I have the feeling, vscode is using an internal console and its environments / paths, etc is correct, when I use bash something is missing ands its not able to resolve assemblies.


@steveharter commented on Fri Jul 14 2017

@danwalmsley try export COREHOST_TRACE=1 and run again to get verbose output. This will tell you where it is looking for the runtime and related assemblies.

It is possible that the version of System.Text.RegularExpressions that is found is older.


@danwalmsley commented on Fri Jul 14 2017

@steveharter i will try on Monday when I’m in front of the affected system and post back. Thanks


@danwalmsley commented on Mon Jul 17 2017

OK so here is the result:

firstly contents of directory:

AvalonStudio					AvalonStudio.Languages.CSharp.pdb		AvalonStudio.pdb
AvalonStudio.Controls.Standard.dll		AvalonStudio.Projects.CPlusPlus.dll		AvalonStudio.runtimeconfig.dev.json
AvalonStudio.Controls.Standard.pdb		AvalonStudio.Projects.CPlusPlus.pdb		AvalonStudio.runtimeconfig.json
AvalonStudio.Debugging.GDB.JLink.dll		AvalonStudio.Projects.OmniSharp.dll		AvaloniaEdit.dll
AvalonStudio.Debugging.GDB.JLink.pdb		AvalonStudio.Projects.OmniSharp.pdb		AvaloniaEdit.pdb
AvalonStudio.Debugging.GDB.Local.dll		AvalonStudio.Projects.Standard.dll		CorApi.NetCore2.dll
AvalonStudio.Debugging.GDB.Local.pdb		AvalonStudio.Projects.Standard.pdb		CorApi.NetCore2.pdb
AvalonStudio.Debugging.GDB.OpenOCD.dll		AvalonStudio.Repository.dll			CorApi.Portable.dll
AvalonStudio.Debugging.GDB.OpenOCD.pdb		AvalonStudio.Repository.pdb			CorApi.Portable.pdb
AvalonStudio.Debugging.GDB.Remote.dll		AvalonStudio.Toolchains.Clang.dll		CorApi2.NetCore2.dll
AvalonStudio.Debugging.GDB.Remote.pdb		AvalonStudio.Toolchains.Clang.pdb		CorApi2.NetCore2.pdb
AvalonStudio.Debugging.GDB.dll			AvalonStudio.Toolchains.GCC.dll			Mono.Debugging.Win32.dll
AvalonStudio.Debugging.GDB.pdb			AvalonStudio.Toolchains.GCC.pdb			Mono.Debugging.Win32.pdb
AvalonStudio.Debugging.dll			AvalonStudio.Toolchains.LocalGCC.dll		Mono.Debugging.dll
AvalonStudio.Debugging.pdb			AvalonStudio.Toolchains.LocalGCC.pdb		Mono.Debugging.pdb
AvalonStudio.Extensibility.dll			AvalonStudio.Toolchains.STM32.dll		PortableCom.dll
AvalonStudio.Extensibility.pdb			AvalonStudio.Toolchains.STM32.pdb		PortableCom.pdb
AvalonStudio.LanguageSupport.TypeScript.dll	AvalonStudio.Toolchains.Standard.dll		Templates
AvalonStudio.LanguageSupport.TypeScript.pdb	AvalonStudio.Toolchains.Standard.pdb		libhostfxr.dylib
AvalonStudio.Languages.CPlusPlus.dll		AvalonStudio.deps.json				libhostpolicy.dylib
AvalonStudio.Languages.CPlusPlus.pdb		AvalonStudio.dll				native
AvalonStudio.Languages.CSharp.dll		AvalonStudio.dll.config				publish

@danwalmsley commented on Mon Jul 17 2017

The error message when I run the application normally. It can’t find AvaloniaEdit.dll, which is included (see prev post with dir listing)

$ dotnet ./AvalonStudio.dll

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> OmniXaml.LoadException: Error loading XAML: System.IO.FileLoadException: Could not load file or assembly 'AvaloniaEdit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. An internal error occurred.
 (Exception from HRESULT: 0x8007054F)
File name: 'AvaloniaEdit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at OmniXaml.Typing.TypeRepository.GetByPrefix(String prefix, String typeName)
   at Avalonia.Markup.Xaml.Converters.SelectorTypeConverter.<>c__DisplayClass2_0.<ConvertFrom>b__0(String t, String ns)
   at Avalonia.Markup.Xaml.Parsers.SelectorParser.Parse(String s)
   at OmniXaml.Typing.CommonValueConversion.ConverterStep.TryConvert(Object value, XamlType targetType, IValueContext valueContext, Object& result)
   at OmniXaml.Typing.CommonValueConversion.TryConvert(Object value, XamlType targetType, IValueContext valueContext, Object& result)
   at OmniXaml.ObjectAssembler.StateCommuter.AssignChildToParentProperty()
   at OmniXaml.ObjectAssembler.StateCommuter.AssociateCurrentInstanceToParent()
   at OmniXaml.ObjectAssembler.Commands.ValueCommand.Execute()
   at OmniXaml.ObjectAssembler.ObjectAssembler.Process(Instruction instruction)
   at OmniXaml.TemplateHostingObjectAssembler.Process(Instruction instruction)
   at OmniXaml.XmlParser.Parse(IEnumerable`1 xamlNodes)
   at OmniXaml.XmlLoader.Load(Stream stream, IParser parser)

 ---> System.IO.FileLoadException: Could not load file or assembly 'AvaloniaEdit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. An internal error occurred.
 (Exception from HRESULT: 0x8007054F)
   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at OmniXaml.Typing.TypeRepository.GetByPrefix(String prefix, String typeName)
   at Avalonia.Markup.Xaml.Converters.SelectorTypeConverter.<>c__DisplayClass2_0.<ConvertFrom>b__0(String t, String ns)
   at Avalonia.Markup.Xaml.Parsers.SelectorParser.Parse(String s)
   at OmniXaml.Typing.CommonValueConversion.ConverterStep.TryConvert(Object value, XamlType targetType, IValueContext valueContext, Object& result)
   at OmniXaml.Typing.CommonValueConversion.TryConvert(Object value, XamlType targetType, IValueContext valueContext, Object& result)
   at OmniXaml.ObjectAssembler.StateCommuter.AssignChildToParentProperty()
   at OmniXaml.ObjectAssembler.StateCommuter.AssociateCurrentInstanceToParent()
   at OmniXaml.ObjectAssembler.Commands.ValueCommand.Execute()
   at OmniXaml.ObjectAssembler.ObjectAssembler.Process(Instruction instruction)
   at OmniXaml.TemplateHostingObjectAssembler.Process(Instruction instruction)
   at OmniXaml.XmlParser.Parse(IEnumerable`1 xamlNodes)
   at OmniXaml.XmlLoader.Load(Stream stream, IParser parser)
   --- End of inner exception stack trace ---
   at OmniXaml.XmlLoader.Load(Stream stream, IParser parser)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Stream stream, Object rootInstance, Uri uri)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Uri uri, Uri baseUri, Object rootInstance)
   at Avalonia.Markup.Xaml.Styling.StyleInclude.get_Loaded()
   at Avalonia.Markup.Xaml.Styling.StyleInclude.FindResource(String name)
   at Avalonia.Styling.Styles.FindResource(String name)
   at Avalonia.Styling.StyleExtensions.FindStyleResource(IStyleHost control, String name)
   at Avalonia.Markup.Xaml.Data.StyleResourceBinding.Initiate(IAvaloniaObject target, AvaloniaProperty targetProperty, Object anchor, Boolean enableDataValidation)
   at Avalonia.Styling.Setter.Apply(IStyle style, IStyleable control, IObservable`1 activator)
   at Avalonia.Styling.Style.Attach(IStyleable control, IStyleHost container)
   at Avalonia.Styling.Styles.Attach(IStyleable control, IStyleHost container)
   at Avalonia.Styling.Styles.Attach(IStyleable control, IStyleHost container)
   at Avalonia.Styling.Styles.Attach(IStyleable control, IStyleHost container)
   at Avalonia.Styling.Styler.ApplyStyles(IStyleable control, IStyleHost styleHost)
   at Avalonia.Controls.TopLevel..ctor(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolver)
   at Avalonia.Controls.WindowBase..ctor(IWindowBaseImpl impl, IAvaloniaDependencyResolver dependencyResolver)
   at Avalonia.Controls.Window..ctor(IWindowImpl impl)
   at AvalonStudio.Controls.SplashScreen..ctor()
   at AvalonStudio.BootScreen..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance[T]()
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider)
   at AvalonStudio.App.Main(String[] args)
Abort trap: 6

@danwalmsley commented on Mon Jul 17 2017

log.txt

log is very long so put it in the attached text file.


@steveharter commented on Mon Jul 17 2017

Do you know why the error message changed from failing to load System.Text.RegularExpressions to AvaloniaEdit? Does it still work under different vscode settings?

The triggering exception appears to be OmniXaml.LoadException, wrapping a System.IO.FileLoadException for AvaloniaEdit.dll. From the log, that assembly appears to be found by CoreClr at /Users/richard/avalon/AvalonStudio/AvalonStudio/AvalonStudio/bin/Debug/netcoreapp2.0/osx.10.12-x64/AvaloniaEdit.dll.

However I would guess that OmniXaml is doing a custom load of the AvaloniaEdit.dll and is not using the same directory as CoreClr to find that assembly. Perhaps it needs to intercept the assembly resolving events?

Other misc from the log: App base location: /Users/richard/avalon/AvalonStudio/AvalonStudio/AvalonStudio/bin/Debug/netcoreapp2.0/osx.10.12-x64 App location: Users/richard/avalon/AvalonStudio/AvalonStudio/AvalonStudio/bin/Debug/netcoreapp2.0/osx.10.12-x64/AvalonStudio.dll Launch host: /usr/local/share/dotnet/dotnet JIT_PATH: /Users/richard/.nuget/packages/runtime.osx-x64.microsoft.netcore.app/2.0.0-preview2-25407-01/runtimes/osx-x64/native/libclrjit.dylib Probing directory: /Users/richard/.nuget/packages/ with several subdirectories (not complete): lib/netstandard1.1 Avalonia.Direct2D1/0.5.1-build3417-alpha avalonia.direct2d1/0.5.1-build3417-alpha/lib/net45 Avalonia.Gtk3/0.5.1-build3417-alpha avalonia.win32/0.5.1-build3417-alpha/lib/netstandard1.1 Avalonia.Skia.Desktop/0.5.1-build3417-alpha avalonia.skia.desktop/0.5.1-build3417-alpha/lib/netstandard1.3 Avalonia.Xaml.Behaviors/0.5.0 avalonia.xaml.behaviors/0.5.0/lib/netstandard1.1 avalonia/0.5.1-build3417-alpha/lib/netcoreapp1.0/


@danwalmsley commented on Thu Jul 20 2017

@steveharter sorry for delay, my colleague with mac is away, so I will come back to you once we have access to mac, to give you more information. Thanks Dan


@danwalmsley commented on Mon Jul 24 2017

@steveharter Ok I don’t know why the error message changed, i rebuilt from scratch and the error went back to original one. I have attached a new log file, and linked a youtube video so you can see what is happening.

youtube shows me using the console in vscode to invoke the app, and it working. then me using terminal, and it not working.

avalonstudio.txt

https://www.youtube.com/watch?v=v8C_aJm6WTg&feature=youtu.be

thanks for your patience as I have been slow to respond.


@steveharter commented on Mon Jul 24 2017

From the log, it looks like a previous version of dotnet was installed as it is finding the dotnet executable version 1.0.1 instead of 2.0 preview version. Although I’m not aware of any problems with this (as it should be in “muxer” mode and just forward to the 2.0 preview location) can you please try to replace the dotnet executable with the 2.0 version? At least we can rule that out and then go from there. Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:34 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
janvorlicommented, Sep 15, 2017

@steveharter the “A device attached to the system is not functioning” could lead us to figure out the culprit. Could you please run it under dtruss? Like sudo dtruss dotnet ./AvalonStudio.dll That should show syscalls it was making and that means also file open requests. The error makes me think that we might be accessing some weird code path.

1reaction
danwalmsleycommented, Jul 25, 2017

@livarcocc

Also, keep in mind that the CLI does not support XMAL.

we built our own XAML framework 😉 see here: https://github.com/AvaloniaUI/Avalonia

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run dotnet core application on Mac using ...
Unable to run dotnet core application on Mac using dotnet command, but works under vscode #8529. Closed. janvorli opened this issue on Jul ......
Read more >
It was not possible to run: dotnet run in visual studio code ...
It's a common cause of confusion that the dotnet run command needs an SDK to work. dotnet run , unlike what the name...
Read more >
Install .NET on macOS
NET apps ), see Working with macOS Catalina Notarization. ... NET CLI commands available for the terminal session in which it was run....
Read more >
Troubleshoot .NET tool usage issues
Possible reasons for this include: * You misspelled a built-in dotnet command. * You intended to execute a .NET program, but dotnet-xyz does ......
Read more >
Cannot debug net6.0-macos Apps - Developer Community
Install the most recent Visual Studio 2022 for Mac release from ... NET 7 and preview bits to make this work but at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found