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.
We have a Xamarin.Forms android and ios app which has been performing well for a number of years now. The latest version has been in prod since early 2017, and has had very few crashes. Until recently!
One of our android clients started getting exceptions when connecting to our ServiceStack powered API service. Now our API service hasn't been changed since the App deployment (Jan 2017), and we've just started getting these errors in Dec 2017.
The details from the app logging on their device reveal the following.
Exception: The type initializer for 'System.AndroidPlatform' threw an exception.StackTrace: at System.Net.WebProxy.CreateDefaultProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <10a067eff09446018662189377d200e9>:0
at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <10a067eff09446018662189377d200e9>:0
at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor (System.Uri)
at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <10a067eff09446018662189377d200e9>:0
at ServiceStack.PclExport.CreateWebRequest (System.String requestUri, System.Nullable`1[T] emulateHttpViaPost) [0x00000] in <0c56e395a4c44995b59b57d9e7ca7331>:0
at ServiceStack.ServiceClientBase.PrepareWebRequest (System.String httpMethod, System.String requestUri, System.Object request, System.Action`1[T] sendRequestAction) [0x0004e] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.SendRequest (System.String httpMethod, System.String requestUri, System.Object request) [0x00014] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Send[TResponse] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00075] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (System.String relativeOrAbsoluteUrl) [0x00000] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (ServiceStack.IReturn`1[T] requestDto) [0x00012] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at [OUR APP].PCL.Services.Agent.IsAwake () [0x00013] in <cb1d96a8f02e4d9f92152b248e31ee23>:0
Source: System
Has Inner Exceptions: True
Inner Exception 1: Couldn't bind to method 'CertStoreLookup'.
StackTrace: at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, System.Reflection.BindingFlags bflags, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x000f9] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x00014] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.AndroidPlatform..cctor () [0x0002d] in <10a067eff09446018662189377d200e9>:0
Source: mscorlib
Has Inner Exceptions: False
25/01/18 11:01:19 IsAwake The type initializer for 'System.AndroidPlatform' threw an exception. Endpoint http://OURENDPOINT/
25/01/18 11:01:18 Sync Started
I have been able to reproduce this error, but only in a release build. It all works fine in DEBUG mode, when using the Shared Runtime Framework. So it's leading me to think that the release build packaging of Android is removing something that Android requires, but I can't for the life of me figure out what it is.
Version Info
VS2017 15.5.6
Xamarin 4.8.0.760
Xamarin.Android SDK 8.1.5.0
Xamarin.Forms v1.5.0.6447 (in PROD)
ServiceStack.Client (PCL proj via NuGet) 4.0.40 (in PROD)
Installed SDK's
8.0.0(26), 7.1.1(25), 7.0(24), 6.0(23), 5.01(21), 4.4.2(19),
Build Config
Target Framework: 6.0 (v23)
Minimum SDK: 4.0.3 (v15)
**DEBUG**
Use Shared Runtime : true
Use Fast Deploy : false
Linking: SDK Assemblies only
**RELEASE**
Use Shared Runtime : false
Use Fast Deploy : false
Linking: none
I've been trying many things..
I've updated the Target Framework to 7.1 with minimum to 5.0, removed all Xamarin and ServiceStack references, and then installed the new ones that target the framework level.
Everything always works in DEBUG, but not in RELEASE.
Would greatly appreciate any assistance anyone could supply..
TIA.
EDIT
After performing the steps suggested by #mahmoud-kamel, I get the following errors for the RELEASE build.
Severity Code Description Project File Line Source Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void Android.Support.V4.App.FragmentActivity::n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(System.IntPtr,System.IntPtr,System.Int32,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.Android.Support.Fragment.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [OUR APP].DroidApp C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1696 Build
This turned out to be a mismatch of assemblies referenced by the project.
After looking at the internals of the System.dll's in the bin/debug and bin/release folders, and comparing those of a new project from VS template, we were able to determine that after the project was upgraded to use the latest SDK, MSBuild wasn't retrieving the SYSTEM.dll from the correct ReferenceAssemblies folder location.
Doing a search for "ReferenceAssemblies" on my pc brings up about 4 locations!
The correct location (on my pc) is the following folder, with the Android version number folder (eg. "v8.0".
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\
I hope this helps someone and saves them the hours I spent on this!
put Target framework to the latest and the minimum is version 16
right click on Android project then go to options make sure that Release mode in linker tab and choose link SDK Assemblies only
save all changes then clean all solution , close the project and visual studio
go to folder of project then delete bin, obj folders
open visual studio , and try to start deploy project in release mode
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.