{"id":1099,"date":"2014-12-17T16:43:39","date_gmt":"2014-12-17T11:13:39","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=1099"},"modified":"2014-12-17T16:43:39","modified_gmt":"2014-12-17T11:13:39","slug":"ilmerge-issues","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2014\/12\/ilmerge-issues\/","title":{"rendered":"ILMerge Issues"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Introduction<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">A lot of\u00a0times when we are developing plug-ins and workflows, we are in need of adding multiple assemblies (.dll) into our main solution. The current scenario that\u00a0we experienced is that we used itextsharp.dll assembly to edit the PDF Forms from within\u00a0our plug-in and for that we have to merge the itextsharp.dll with our plug-in assembly.<\/p>\n<p style=\"text-align: justify;\">The external itextsharp.dll file contained the special features which was the most important part of our solution.<\/p>\n<p style=\"text-align: justify;\">We usually use ILMerge to merge these assemblies and ILMerge has made it successful to an extent, but sometimes we are stuck and our assemblies are not merged or in many cases it so happens that after the assemblies are merged and\u00a0when we try to execute the workflows\/plug-ins,\u00a0we get an exception as <strong>\u201cSystem.TypeLoad exception\u201d.<\/strong><\/p>\n<p style=\"text-align: justify;\">In the latter condition, we have a merged assembly yet\u00a0we are unsuccessful in implementing our logic. Even after spending hours\u00a0on Google,\u00a0we fail to come to any concrete solution and simply\u00a0think what to do next.<\/p>\n<p style=\"text-align: justify;\">So here is the solution, we just need to use our command prompt and write a simple command to get this working. The command is as follows:<\/p>\n<p>&#8220;C:\\Program Files\\Microsoft\\ILMerge\\ILMerge.exe&#8221; \/keyfile:&#8221;E:\\XXXX \\SigningFile.snk&#8221; \/ndebug \u00a0\/targetplatform:4.0, &#8220;C:\\Program Files\\Reference assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0&#8243; \u00a0\/out:&#8221;E:\\XXXX.dll&#8221; &#8220;E:\\XXX.CRM.Plugin.dll&#8221; &#8220;E:\\itextsharp.dll&#8221;<\/p>\n<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Command explanation<\/strong><\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"779\">&#8220;C:\\Program Files\\Microsoft\\ILMerge\\ILMerge.exe&#8221;<\/td>\n<td width=\"300\">Path to your ILMerge dll.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">\/keyfile:&#8221;E:\\XXXX \\SigningFile.snk&#8221;<\/td>\n<td width=\"300\">Path of your sign file.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">\/ndebug<\/td>\n<td width=\"300\">ILMerge creates a .pdb file for the output assembly and merges into it any .pdb files found for input assemblies.<\/p>\n<p>Use this command if you do not want to create the .pdb file.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">\/targetplatform:4.0, &#8220;C:\\Program Files\\Reference assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0&#8221;<\/td>\n<td width=\"300\">Path of your .Net 4.0 framework dll.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">\/out:&#8221;E:\\XXXX.dll&#8221;<\/td>\n<td width=\"300\">Path of your final dll.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">&#8220;E:\\XXX.CRM.Plugin.dll&#8221;<\/td>\n<td width=\"300\">Path of your plugin\/ workflow assembly.<\/td>\n<\/tr>\n<tr>\n<td width=\"779\">&#8220;E:\\itextsharp.dll&#8221;<\/td>\n<td width=\"300\">Path of your additional assembly.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\"><strong>Reason<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">Now, you might ask that why do we take the trouble of\u00a0using command prompt instead of ILMerge UI?<\/p>\n<p style=\"text-align: justify;\">The reason to use command prompt is that the target framework used in the ILMerge UI is 4.0.30319 whereas the expected target framework is 4.0 and hence we receive the <strong>Sysytem.TypeLoad\u00a0<\/strong>exception whenever we execute our plug-in\/workflow.<\/p>\n<p style=\"text-align: justify;\"><strong><span style=\"text-decoration: underline;\">Conclusion<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\">The above command is very useful for merging the different assemblies required by our solution and hence it proves to be helpful in implementing our logic.<\/p>\n<p style=\"text-align: justify;\">Hope this helps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction A lot of\u00a0times when we are developing plug-ins and workflows, we are in need of adding multiple assemblies (.dll) into our main solution. The current scenario that\u00a0we experienced is that we used itextsharp.dll assembly to edit the PDF Forms from within\u00a0our plug-in and for that we have to merge the itextsharp.dll with our plug-in\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2014\/12\/ilmerge-issues\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[21,22,24],"tags":[299,516,592,911],"class_list":["post-1099","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","tag-command","tag-dll","tag-dynamics-crm","tag-ilmerge"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=1099"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1099\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=1099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=1099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=1099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}