diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index c597da69a..583017b9f 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -32,6 +32,8 @@ namespace CefSharp { public ref class Cef sealed { + #define InitializedCheck() if (!_initialized) throw gcnew Exception(__FUNCTION__ + " requires that CEF has been initialized first.") + private: static Object^ _sync; @@ -370,6 +372,8 @@ namespace CefSharp /// A the global cookie manager static ICookieManager^ GetGlobalCookieManager() { + InitializedCheck(); + auto cookieManager = CefCookieManager::GetGlobalManager(NULL); if (cookieManager.get()) { @@ -389,6 +393,8 @@ namespace CefSharp /// A blocking cookie manager static ICookieManager^ GetBlockingCookieManager() { + InitializedCheck(); + auto cookieManager = CefCookieManager::GetBlockingManager(); if (cookieManager.get()) { @@ -500,6 +506,8 @@ namespace CefSharp /// Returns List of structs. static Task^>^ GetPlugins() { + InitializedCheck(); + auto taskVisitor = gcnew TaskWebPluginInfoVisitor(); CefRefPtr visitor = new PluginVisitor(taskVisitor); @@ -550,6 +558,8 @@ namespace CefSharp /// Returns the global request context or null. static IRequestContext^ GetGlobalRequestContext() { + InitializedCheck(); + auto context = CefRequestContext::GetGlobalContext(); if (context.get())