Description
I’m trying to use the Zoom Client SDK in a .NET 4.7.2 Web API. I’m trying to setup my wrapper as a Singleton so I’m instantiating it in the WebApiConfig.Register method but even here it won’t work (instantiating it inside the controller methods created a similar Exception).
Here is my code:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
DebugLogService debugService = new DebugLogService();
ZoomService zoomService = new ZoomService(debugService);
Task<bool> initializeZoom = zoomService.InitializationAsync("...", "...");
initializeZoom.Wait();
bool result = initializeZoom.Result;
debugService.Log($"result = {result}");
}
}
Support for this is a little limited, but I can try and help. Is it possible you just need to add “ZOOM_SDK_DOTNET_WRAP.” before the InitParam and the CZoomSDKeDotNetWrap?
public static async void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
ZOOM_SDK_DOTNET_WRAP.InitParam param = new ZOOM_SDK_DOTNET_WRAP.InitParam
{
web_domain = "https://zoom.us",
config_opts = { optionalFeatures = 1 << 5 }, // Using Zoom Customized UI
};
SDKError error = ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.Initialize(param);
}
I’m still getting the same exception. My guess is that the static instance sits outside of the memory space in MVC solutions.
I will note that I’m able to call the C++ SDK from a DLL import from inside my MVC application, so this seems to point to something in the way the memory space is setup in the C# wrapper.
Some further investigation: looks like it’s not the Initialize method in the C# wrapper. Any reference to doing anything to ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance throws that AccessViolationException. Looks like however the static instance is setup in the wrapper causes issues in MVC.
Hey @Michael_Condon, in my existing application there is no need to create the static instance as far as I’ve seen. Can you give me any example? In my WPF forms application where this is working it just starts using the static instance.
As far as I know in C# there is no need to “create a static instance” if you’re referring to instantiation. Or are you referring to something else that needs to be done?
The reason you would make it static is to make the “Instance” a global singleton. So that there is always only one DotNetWrap and it is available whenever needed.