I am trying to use postsharp on .net core 2.
I have added Postsharp 5.1.19 (preview) however, I am getting the following error when I try to build the project.
/Users/me/.nuget/packages/postsharp/5.1.9-preview/build/PostSharp.targets(5,5): Error MSB4060: The "PostSharp30" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name. (MSB4060) `
Here is a detailed explanation which is essentially not aware that I am on MAC and still looking for (kernel32) and some dlls:
/Users/me/.nuget/packages/postsharp/5.1.9-preview/build/PostSharp.targets(5,5): Error MSB4061: The "PostSharp30" task could not be instantiated from "/Users/me/.nuget/packages/postsharp/5.1.9-preview/build/PostSharp.MSBuild.v5.1.9.Release.dll".
System.TypeInitializationException: The type initializer for 'PostSharp.Compiler.Client.BuildClient' threw an exception. ---> System.DllNotFoundException: kernel32
at (wrapper managed-to-native) PostSharp.Compiler.Client.ProcessUtilities.GetCurrentProcess()
at PostSharp.Compiler.Client.ProcessUtilities.GetParentProcesses () [0x00006] in <7cce0190f299453c822c4cfb425f86da>:0
at PostSharp.Compiler.Client.ProcessUtilities.DetectUnattendedProcess (System.String& log) [0x0002f] in <7cce0190f299453c822c4cfb425f86da>:0
at PostSharp.Compiler.Client.BuildClient..cctor () [0x00016] in <7cce0190f299453c822c4cfb425f86da>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at PostSharp.MSBuild.PostSharp30..ctor () [0x00018] in <7cce0190f299453c822c4cfb425f86da>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 (MSB4061)`
How can I get this working?
As you can read in the announcement:
PostSharp 5.1 will still only support Windows as the only build
platform.
So even though .NET Core projects are supported, you can build with PostSharp only on Windows, and as you said - you are on MAC.
Related
I'm trying to get the default audio endpoint using CSCore (https://github.com/filoe/cscore) running in Unity and I'm receiving a System.NotSupportedException. I'm testing this with the Unity NUnit test framework. Strangely, when running the code in the editor it works, but builds receive this exception. Can somebody explain why this is occurring?
The builds I'm doing are x64, and I checked that the DLL I'm using has been built for both x86 and x64. I'm using the 1.2.0 Release DLL. The test code and exception stack trace are provided below:
[Test]
public void GetAudioEndpoint_Default_NoException()
{
Assert.DoesNotThrow(delegate ()
{
var deviceEnumerator = new MMDeviceEnumerator();
var device = deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
});
}
GetAudioEndpoint_Default_NoException (0.039s)
---
Expected: No Exception to be thrown
But was: <System.NotSupportedException: Specified method is not supported.
at (wrapper cominterop) CSCore.CoreAudioAPI.MMDeviceEnumerator+MMDeviceEnumeratorObject..ctor()
at CSCore.CoreAudioAPI.MMDeviceEnumerator.CreateMmDeviceEnumerator () [0x00000] in <b6880cc671004d3aa0cc66420dbddb79>:0
at CSCore.CoreAudioAPI.MMDeviceEnumerator..ctor () [0x00000] in <b6880cc671004d3aa0cc66420dbddb79>:0
at CSCore.Tests.DeviceTests+<>c.<GetAudioEndpoint_Default_NoException>b__0_0 () [0x00001] in ***\DeviceTests.cs:13
at NUnit.Framework.Constraints.ThrowsConstraint+VoidInvocationDescriptor.Invoke () [0x00001] in <59819be142c34115ade688f6962021f1>:0
at NUnit.Framework.Constraints.ThrowsConstraint+ExceptionInterceptor.Intercept (System.Object invocation) [0x0000a] in <59819be142c34115ade688f6962021f1>:0 >
---
at CSCore.Tests.DeviceTests.GetAudioEndpoint_Default_NoException () [0x00001] in ***\DeviceTests.cs:11
The reason ended up being that although my scripting runtime version was .NET 4.X, my API Compatibility level was still set to 2.0. This meant that Unity was leaving out required .NET 4.X dependencies that CSCore relied upon.
The correct configuration, accessed from Player settings:
I am trying to run an C# program on my Raspberry Pi 3 using mono. The program starts correctly, but as soon as I reach a point where I use some OpenCV libraries the program error with the following output:
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: opencv_core220
at (wrapper managed-to-native) Emgu.CV.CvInvoke:cvRedirectError (Emgu.CV.CvInvoke/CvErrorCallback,intptr,intptr)
at Emgu.CV.CvInvoke..cctor () [0x00023] in <4f43ef68be294203a100f85f9cebb2b6>:0
--- End of inner exception stack trace ---
at Emgu.CV.Image`2[TColor,TDepth].AllocateData (System.Int32 rows, System.Int32 cols, System.Int32 numberOfChannels) [0x0002e] in <4f43ef68be294203a100f85f9cebb2b6>:0
at Emgu.CV.Image`2[TColor,TDepth].set_Bitmap (System.Drawing.Bitmap value) [0x00050] in <4f43ef68be294203a100f85f9cebb2b6>:0
at Emgu.CV.Image`2[TColor,TDepth]..ctor (System.Drawing.Bitmap bmp) [0x00008] in <4f43ef68be294203a100f85f9cebb2b6>:0
at App.Program.Main (System.String[] args) [0x00122] in <b44d2f4f9f83495091806ba3e6a1570f>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: opencv_core220
at (wrapper managed-to-native) Emgu.CV.CvInvoke:cvRedirectError (Emgu.CV.CvInvoke/CvErrorCallback,intptr,intptr)
at Emgu.CV.CvInvoke..cctor () [0x00023] in <4f43ef68be294203a100f85f9cebb2b6>:0
--- End of inner exception stack trace ---
at Emgu.CV.Image`2[TColor,TDepth].AllocateData (System.Int32 rows, System.Int32 cols, System.Int32 numberOfChannels) [0x0002e] in <4f43ef68be294203a100f85f9cebb2b6>:0
at Emgu.CV.Image`2[TColor,TDepth].set_Bitmap (System.Drawing.Bitmap value) [0x00050] in <4f43ef68be294203a100f85f9cebb2b6>:0
at Emgu.CV.Image`2[TColor,TDepth]..ctor (System.Drawing.Bitmap bmp) [0x00008] in <4f43ef68be294203a100f85f9cebb2b6>:0
at App.Program.Main (System.String[] args) [0x00122] in <b44d2f4f9f83495091806ba3e6a1570f>:0
The mentioned library "opencv_core220" is a dll located in the same directory as the exe I exececute using mono.
What can I do to fix this problem?
I never worked with mono so far, but I read you can not use dlls on linux, like on windows, but you have to use so-files. But I got no idea how to get them from my dlls.
The program totally works on windows.
There are dlls with .net bytecode and dlls which use windows native code. You need the equivalent files, which use Linux native code!
convert .dll file to .so file and add .so file to /usr/lib. Then run your exe and check
I am trying to run my application which uses cscore (https://github.com/filoe/cscore) and its sub namespace "CSCore.Ffmpeg"
I've already tried what the author explained in "https://github.com/filoe/cscore/blob/master/CSCore.Ffmpeg/Readme.md" ('LD_LIBRARY_PATH=./ mono MyApp.exe') without success.
My question would be how to get it working on Debian 9 using mono.
Additionally i would be grateful if anyone could tell me where i could get the required libraries for my operating system.
This is the stacktrace:
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'CSCore.Ffmpeg.FfmpegCalls' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CSCore.Ffmpeg.FfmpegUtils' threw an exception. ---> System.DllNotFoundException: avutil-55
at (wrapper managed-to-native) CSCore.Ffmpeg.Interops.ffmpeg:av_log_set_callback (intptr)
at CSCore.Ffmpeg.FfmpegCalls.SetLogCallback (CSCore.Ffmpeg.FfmpegCalls+LogCallback callback) [0x00006] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
at CSCore.Ffmpeg.FfmpegUtils..cctor () [0x00025] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
--- End of inner exception stack trace ---
at CSCore.Ffmpeg.Interops.InteropHelper.RegisterLibrariesSearchPath (System.String path) [0x00012] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
at CSCore.Ffmpeg.FfmpegCalls..cctor () [0x0008f] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
--- End of inner exception stack trace ---
at CSCore.Ffmpeg.AvFormatContext..ctor (System.String url) [0x00006] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
at CSCore.Ffmpeg.FfmpegDecoder..ctor (System.String url) [0x00029] in <117ca019c81b40cf9cc0852c6d0ddec3>:0
at AudioTool.AudioClient.AudioStart (System.String url) [0x00001] in <57d1cee9c20047c6a0c5acfeeccbf254>:0
at AudioTool.Program.Main (System.String[] args) [0x00038] in <57d1cee9c20047c6a0c5acfeeccbf254>:0
Thanks in advance
Ok. Solved issue by installing the appropriate linux packages and copying the libraries from '/usr/lib/x86_64-linux-gnu/' into the folder where the application is.
After that i had to look what mono expects by setting the mono loglevel to debug (LD_LIBRARY_PATH=./ MONO_LOG_LEVEL=debug mono MyApp.exe)
An error appeared (something like Mono: DllImport error loading library '/root/bot/Debug/libavutil-55.so': '/root/bot/Debug/libavutil-55.so: cannot open shared object file: No such file or directory'.
)
Then i renamed the existing libavutil.so.55 to libavutil-55.so,I repeated that for every missing include and mono accepted that.
I hope that helps everyone who has a similar problem in future.
Note: This is not a duplicate of the linked question because I'm not looking to develop a Mac application.
So I have a C# application on .NET 4.5 that has the following:
1) Windows Forms
2) References to System.Drawing, EmguCV, Aforge.NET dlls
This works perfectly on my Windows system.
When I try to run the program on a Mac system running OSX using Mono, I get the following error:
exception inside UnhandledException handler: An exception was thrown by the type initializer for System.Windows.Forms.Form
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.Form ---> System.InvalidProgramException: Invalid IL code in System.Drawing.Icon:.ctor (System.IO.Stream): method body is empty.
at (wrapper remoting-invoke-with-check) System.Drawing.Icon:.ctor (System.IO.Stream)
at System.Windows.Forms.ResourceImageLoader.GetIcon (System.String name) [0x00000] in :0
at System.Windows.Forms.Form..cctor () [0x00000] in :0
Has anyone faced anything like this? Appreciate any suggestions.
I have develop a Test Application using WinForm in C# .Net on Visual Studio 2010. Now, I want to run this under Linux using Mono on CentOS. So I tried below command sequence -
[root#localhost TestLinux]# /usr/bin/mono ./Test.exe
I hit an exception
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: gdiplus.dll
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] --- End of inner exception stack trace ---
at <0x00000> <unknown method>
at System.Drawing.Graphics.FromHdcInternal (IntPtr hdc) [0x00000]
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000]
at System.Windows.Forms.XplatUIX11..ctor () [0x00000]
at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000]
at System.Windows.Forms.XplatUI..cctor () [0x00000] --- End of inner exception stack trace ---
at <0x00000> <unknown method>
at System.Windows.Forms.Application.EnableVisualStyles () [0x00000]
at Test.Program.Main () [0x00000]
While doing some research I found that this is due to linking between gdiplus.dll and its counter part libgdiplus.so.0 on linux, need to put its entry in ldconfig cache.
[root#localhost TestLinux]# ldconfig -p | grep libgdiplus
libgdiplus.so.0 (libc6) => /usr/lib/libgdiplus.so.0
The output clearly shows that libgdiplus.so.0 is there in ldconfig cache but still the program is not working. I also tried to add DllMap entry in application configuration as below
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<dllmap dll="gdiplus.dll" target="libgdiplus.so.0"/>
</configuration>
Please let me know if anybody stumbled upon this in past.
You have traced the error wrong.
Your mono version does not support EnableVisualStyles.
Upgrade to a version, which supports it ( as far as i remember it is >= 2.9 ) or try to disable this feature in Your .net application, which will result in "not so nice ui elements".
For me it worked, as i was working on gentoo.
Suddenly, after a emerge, my mono application did not crash anymore.
Also be sure that libgdiplus.so.0 is actually installed and on the path, it is not by default in mono. But yes, the main thing is CentOS comes with an outdated version of mono by default.