{"action":"created","issue":{"url":"https://api.github.com/repos/ioncodes/dnpatch/issues/48","repository_url":"https://api.github.com/repos/ioncodes/dnpatch","labels_url":"https://api.github.com/repos/ioncodes/dnpatch/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/ioncodes/dnpatch/issues/48/comments","events_url":"https://api.github.com/repos/ioncodes/dnpatch/issues/48/events","html_url":"https://github.com/ioncodes/dnpatch/issues/48","id":345556675,"node_id":"MDU6SXNzdWUzNDU1NTY2NzU=","number":48,"title":"Exception when saving","user":{"login":"paulnd","id":6693239,"node_id":"MDQ6VXNlcjY2OTMyMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/6693239?v=4","gravatar_id":"","url":"https://api.github.com/users/paulnd","html_url":"https://github.com/paulnd","followers_url":"https://api.github.com/users/paulnd/followers","following_url":"https://api.github.com/users/paulnd/following{/other_user}","gists_url":"https://api.github.com/users/paulnd/gists{/gist_id}","starred_url":"https://api.github.com/users/paulnd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulnd/subscriptions","organizations_url":"https://api.github.com/users/paulnd/orgs","repos_url":"https://api.github.com/users/paulnd/repos","events_url":"https://api.github.com/users/paulnd/events{/privacy}","received_events_url":"https://api.github.com/users/paulnd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-29T19:36:59Z","updated_at":"2018-07-29T19:47:54Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nThank you for providing a very useful library.\r\n\r\nI'm unfortunately having a problem with a simple example:\r\n\r\nException:\r\n```\r\ndnlib.DotNet.Writer.ModuleWriterException\r\n  HResult=0x80131500\r\n  Message=Found some other method's instruction or a removed instruction. You probably removed an instruction that is the target of a branch instruction or an instruction that's the first/last instruction in an exception handler.\r\n  Source=dnlib\r\n  StackTrace:\r\n   at dnlib.DotNet.DummyLogger.Log(Object sender, LoggerEvent loggerEvent, String format, Object[] args)\r\n   at dnlib.DotNet.Writer.ModuleWriterBase.dnlib.DotNet.ILogger.Log(Object sender, LoggerEvent loggerEvent, String format, Object[] args)\r\n   at dnlib.DotNet.Writer.MetaData.dnlib.DotNet.Writer.IWriterError.Error(String message)\r\n   at dnlib.DotNet.Writer.MethodBodyWriter.ErrorImpl(String message)\r\n   at dnlib.DotNet.Writer.MethodBodyWriterBase.GetOffset(Instruction instr)\r\n   at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteShortInlineBrTarget(BinaryWriter writer, Instruction instr)\r\n   at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteOperand(BinaryWriter writer, Instruction instr)\r\n   at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteInstruction(BinaryWriter writer, Instruction instr)\r\n   at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteInstructions(BinaryWriter writer)\r\n   at dnlib.DotNet.Writer.MethodBodyWriter.WriteFatHeader()\r\n   at dnlib.DotNet.Writer.MethodBodyWriter.Write()\r\n   at dnlib.DotNet.Writer.MetaData.WriteMethodBodies()\r\n   at dnlib.DotNet.Writer.MetaData.Create()\r\n   at dnlib.DotNet.Writer.MetaData.CreateTables()\r\n   at dnlib.DotNet.Writer.ModuleWriter.WriteImpl()\r\n   at dnlib.DotNet.Writer.ModuleWriterBase.Write(Stream dest)\r\n   at dnlib.DotNet.Writer.ModuleWriterBase.Write(String fileName)\r\n   at dnlib.DotNet.ModuleDef.Write(String filename)\r\n   at dnpatch.PatchHelper.Save(String name)\r\n   at dnpatch.Patcher.Save(String name)\r\n   at My_Patcher.Program.Main(String[] args) in E:\\Documents\\Visual Studio 2017\\My_Patcher\\My_Patcher\\Program.cs:line 25\r\n```\r\nand this is the code\r\n```\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing dnlib.DotNet;\r\nusing dnlib.DotNet.Emit;\r\nusing dnpatch;\r\n\r\nnamespace My_Patcher\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            Patcher p = new Patcher(\"Test.1.Server.exe\");\r\n            Target target = new Target()\r\n            {\r\n                Namespace = \"ns0\",\r\n                Class = \"GClass2\",\r\n                Method = \"method_30\",\r\n                Indices = new[] { 26, 27 }\r\n            };\r\n            p.RemoveInstruction(target);\r\n            p.Save(\"Test.1.Server_patched.exe\");\r\n        }\r\n    }\r\n}\r\n```\r\nI've downloaded and referenced dnpatch.dll and dnlib.dll from the releases zip and don't have any errors or warnings when compiling.\r\n\r\nI'll be very grateful for your assistance please. \r\n\r\nthanks"},"comment":{"url":"https://api.github.com/repos/ioncodes/dnpatch/issues/comments/408701061","html_url":"https://github.com/ioncodes/dnpatch/issues/48#issuecomment-408701061","issue_url":"https://api.github.com/repos/ioncodes/dnpatch/issues/48","id":408701061,"node_id":"MDEyOklzc3VlQ29tbWVudDQwODcwMTA2MQ==","user":{"login":"paulnd","id":6693239,"node_id":"MDQ6VXNlcjY2OTMyMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/6693239?v=4","gravatar_id":"","url":"https://api.github.com/users/paulnd","html_url":"https://github.com/paulnd","followers_url":"https://api.github.com/users/paulnd/followers","following_url":"https://api.github.com/users/paulnd/following{/other_user}","gists_url":"https://api.github.com/users/paulnd/gists{/gist_id}","starred_url":"https://api.github.com/users/paulnd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulnd/subscriptions","organizations_url":"https://api.github.com/users/paulnd/orgs","repos_url":"https://api.github.com/users/paulnd/repos","events_url":"https://api.github.com/users/paulnd/events{/privacy}","received_events_url":"https://api.github.com/users/paulnd/received_events","type":"User","site_admin":false},"created_at":"2018-07-29T19:47:54Z","updated_at":"2018-07-29T19:47:54Z","author_association":"NONE","body":"no, unfortunately not, same exception message"}}
{"actor":{"display_login":"paulnd"}}