I complained that I haven’t been online for a long time and the account has disappeared. I can apply for another application.
cesharp v62 version, the kernel uses the latest Cef 62 and supports the latest Grid layout. Since the official cefsharp is developed using .net4.5.2, what should I do? I can only use .net4.0. There is no way, I can modify it with the source code myself to compatible.
Carefully analyzing the source code and found:
1.net4.5.2 introduced the async/await keyword. In fact, foreign masters have released the source code. We will directly introduce the code into the cefsharp project. You can use async/await directly in 4.0;
2.net4.5 has expanded the task API, and we only need to implement the corresponding API in .net4.0.
3. The GetTypeInfo extension method errors that are only available in 4.5 are used in the source code. The type it returns is typeinfo. Don't worry about it, delete GetTypeInfo. Just call Type directly.
4. To extend the Task static method, you need to modify the method of calling static methods.
The above are the key points. The following is the source code:
This paragraph of source code supports: async/await:
namespace { public static class TaskEx { public static TaskAwaiter GetAwaiter(this Task task) { return new TaskAwaiter(task); } public static TaskAwaiter<T> GetAwaiter<T>(this Task<T> task) { return new TaskAwaiter<T>(task); } } public struct TaskAwaiter : INotifyCompletion { readonly Task task; internal TaskAwaiter(Task task) { = task; } internal static TaskScheduler TaskScheduler { get { if ( == null) return ; else return (); } } public bool IsCompleted { get { return ; } } public void OnCompleted(Action continuation) { ( delegate (Task task) { continuation(); }, ); } public void GetResult() { try { (); } catch (AggregateException ex) { throw [0]; } } } public struct TaskAwaiter<T> : INotifyCompletion { readonly Task<T> task; internal TaskAwaiter(Task<T> task) { = task; } public bool IsCompleted { get { return ; } } public void OnCompleted(Action continuation) { ( delegate (Task<T> task) { continuation(); }, ); } public T GetResult() { try { return ; } catch (AggregateException ex) { throw [0]; } } } } namespace { public interface INotifyCompletion { void OnCompleted(Action continuation); } public interface ICriticalNotifyCompletion : INotifyCompletion { [SecurityCritical] void UnsafeOnCompleted(Action continuation); } public interface IAsyncStateMachine { void MoveNext(); void SetStateMachine(IAsyncStateMachine stateMachine); } public struct AsyncVoidMethodBuilder { public static AsyncVoidMethodBuilder Create() { return new AsyncVoidMethodBuilder(); } public void SetException(Exception exception) { throw exception; } public void SetResult() { } public void SetStateMachine(IAsyncStateMachine stateMachine) { // Should not get called as we don't implement the optimization that this method is used for. throw new NotImplementedException(); } public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine { (); } public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine { (); } public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { (); } } public struct AsyncTaskMethodBuilder { TaskCompletionSource<object> tcs; public Task Task { get { return ; } } public static AsyncTaskMethodBuilder Create() { AsyncTaskMethodBuilder b; = new TaskCompletionSource<object>(); return b; } public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine { (); } public void SetStateMachine(IAsyncStateMachine stateMachine) { // Should not get called as we don't implement the optimization that this method is used for. throw new NotImplementedException(); } public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine { (); } public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { (); } public void SetResult() { (null); } public void SetException(Exception exception) { (exception); } } public struct AsyncTaskMethodBuilder<T> { TaskCompletionSource<T> tcs; public Task<T> Task { get { return ; } } public static AsyncTaskMethodBuilder<T> Create() { AsyncTaskMethodBuilder<T> b; = new TaskCompletionSource<T>(); return b; } public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine { (); } public void SetStateMachine(IAsyncStateMachine stateMachine) { // Should not get called as we don't implement the optimization that this method is used for. throw new NotImplementedException(); } public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine { (); } public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { AwaitOnCompleted(ref awaiter, ref stateMachine); } public void SetResult(T result) { (result); } public void SetException(Exception exception) { (exception); } } }
This paragraph is an extension of Task
using System; using ; using ; using ; using ; using ; namespace CefSharp { public class TaskEx { public static Task<T> FromResult<T>(T t) { return <T>(() => t); } public static Task Run(Action action) { var tcs = new TaskCompletionSource<object>(); new Thread(() => { try { action(); (null); } catch (Exception ex) { (ex); } }) { IsBackground = true }.Start(); return ; } public static Task<TResult> Run<TResult>(Func<TResult> function) { var tcs = new TaskCompletionSource<TResult>(); new Thread(() => { try { (function()); } catch (Exception ex) { (ex); } }) { IsBackground = true }.Start(); return ; } public static Task Delay(int milliseconds) { var tcs = new TaskCompletionSource<object>(); var timer = new (milliseconds) { AutoReset = false }; += delegate { (); (null); }; (); return ; } } }
Add the above code in C#, when encountering , replace it with , and when encountering .
There is also a place where the error reports GetTypeInfo is reported, and it will be OK if you delete it.
The above CefSharp v62 modification method (supports.net4.0) is all the content I share with you. I hope you can give you a reference and I hope you can support me more.