{"action":"created","issue":{"url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/22","repository_url":"https://api.github.com/repos/0x1mason/GribApi.NET","labels_url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/22/comments","events_url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/22/events","html_url":"https://github.com/0x1mason/GribApi.NET/issues/22","id":134295459,"number":22,"title":"GribApi breaks when running under Windows Forms Application mode","user":{"login":"xavierpena","id":10937807,"avatar_url":"https://avatars.githubusercontent.com/u/10937807?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierpena","html_url":"https://github.com/xavierpena","followers_url":"https://api.github.com/users/xavierpena/followers","following_url":"https://api.github.com/users/xavierpena/following{/other_user}","gists_url":"https://api.github.com/users/xavierpena/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierpena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierpena/subscriptions","organizations_url":"https://api.github.com/users/xavierpena/orgs","repos_url":"https://api.github.com/users/xavierpena/repos","events_url":"https://api.github.com/users/xavierpena/events{/privacy}","received_events_url":"https://api.github.com/users/xavierpena/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-17T14:33:14Z","updated_at":"2016-02-21T04:06:39Z","closed_at":null,"body":"This API looks great and it is something I had been waiting for a while (reading gribs in .net is quite a nightmare). But I stumbled upon this bug that had me scratching my head for a while:\r\n\r\nApparently, in a Windows Forms Application the code breaks if it is called **after** `Application.Run(new FormMain());` ... but not before, in this case it works like a charm (as it does under any case of Console Application mode).\r\n\r\nNot many details are given, just this:\r\n\r\n```\r\n> Loaded 'Grib.Api.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.\r\n> The program '[11188] DbManager.vshost.exe' has exited with code 3 (0x3).\r\n```\r\n\r\nThe line `var gribMessages = new GribFile(filePath)` works fine. The error comes when trying to iterate over each gribMessage. The application exits directly without throwing any exception.\r\n\r\n***\r\n\r\n**Update:**\r\n\r\nThe source of the error is the `GribApiProxyPINVOKE.GribUtilSectionsCopy` in this function of `GribApiProxy.cs`:\r\n\r\n```\r\n  public static GribHandle GribUtilSectionsCopy(GribHandle hfrom, GribHandle hto, int what, out int err) {\r\n\t\tSystem.IntPtr pVal = GribApiProxyPINVOKE.GribUtilSectionsCopy(hfrom.Reference, hto.Reference, what, out err);\r\n\r\n\t\treturn pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);\r\n\t}\r\n```"},"comment":{"url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/comments/186737173","html_url":"https://github.com/0x1mason/GribApi.NET/issues/22#issuecomment-186737173","issue_url":"https://api.github.com/repos/0x1mason/GribApi.NET/issues/22","id":186737173,"user":{"login":"0x1mason","id":4587515,"avatar_url":"https://avatars.githubusercontent.com/u/4587515?v=3","gravatar_id":"","url":"https://api.github.com/users/0x1mason","html_url":"https://github.com/0x1mason","followers_url":"https://api.github.com/users/0x1mason/followers","following_url":"https://api.github.com/users/0x1mason/following{/other_user}","gists_url":"https://api.github.com/users/0x1mason/gists{/gist_id}","starred_url":"https://api.github.com/users/0x1mason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0x1mason/subscriptions","organizations_url":"https://api.github.com/users/0x1mason/orgs","repos_url":"https://api.github.com/users/0x1mason/repos","events_url":"https://api.github.com/users/0x1mason/events{/privacy}","received_events_url":"https://api.github.com/users/0x1mason/received_events","type":"User","site_admin":false},"created_at":"2016-02-21T04:06:39Z","updated_at":"2016-02-21T04:06:39Z","body":"Looks like I've got it fixed for the next release."}}