{"id":9,"date":"2004-07-21T23:04:50","date_gmt":"2004-07-22T03:04:50","guid":{"rendered":"http:\/\/www.hongliangjie.com\/blog\/?p=9"},"modified":"2008-05-31T23:30:54","modified_gmt":"2008-06-01T03:30:54","slug":"dynamic-loadin","status":"publish","type":"post","link":"https:\/\/www.hongliangjie.com\/blog\/2004\/07\/21\/dynamic-loadin\/","title":{"rendered":"\u89e3\u51b3\u4e86\u52a8\u6001\u52a0\u8f7d\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u679c\u7136\uff0c\u5728\u7f51\u4e0a\u67e5\u4e86\u4e00\u4e9b\u8d44\u6599\u4ee5\u540e\uff0c\u7ec8\u4e8e\u52a8\u6001\u52a0\u8f7d\u4e86dll\u5e76\u4e14\u8c03\u7528\u4e86\u91cc\u9762\u7684\u65b9\u6cd5\u3002\u5176\u5b9e\u641e\u61c2\u4e86\u4ee5\u540e\u8fd8\u662f\u5f88\u7b80\u5355\u7684\u3002\u5177\u4f53\u5b9e\u73b0\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre lang=\"csharp\" line=\"1\">\r\nAssembly ass;\r\nass=Assembly.LoadFrom(Server.MapPath(\"\")+\"\\\\bin\\\\kernel.dll\");\r\nType myType=ass.GetType(\"Kernel.DbControl\");\r\nMethodInfo mi=myType.GetMethod(\"ViewAllData\");\r\nObject[] arg=new object[1];\r\narg[0]=Server.MapPath(\"\");\r\nObject obj = Activator.CreateInstance(myType,arg);\r\nTest.DataSource=(DataSet)mi.Invoke(obj,null);\r\nTest.DataBind();\r\n<\/pre>\n<p>\u9996\u5148\u8981\u628adll\u52a0\u8f7d\u8fdb\u6765\u3002\u7136\u540e\u5f97\u5230\u7279\u5b9a\u7684\u7c7b\u540d\u3002\u518d\u5c31\u662f\u5f97\u5230\u8fd9\u4e2a\u7c7b\u91cc\u91cc\u9762\u67d0\u4e2a\u65b9\u6cd5\u3002\u6700\u91cd\u8981\u7684\u4e00\u53e5\u5c31\u662f\uff1aObject obj = Activator.CreateInstance(myType,arg); \u8fd9\u53e5\u7684\u4f5c\u7528\u5c31\u662f\u4f7f\u8fd9\u4e2a\u7c7b\u5b9e\u4f8b\u5316\u3002\u6ce8\u610f\uff0c\u5b9e\u4f8b\u5316\u53ef\u4ee5\u5e26\u4e0a\u53c2\u6570\uff08\u8fd9\u8981\u770b\u6784\u9020\u51fd\u6570\u662f\u4ec0\u4e48\u6837\u5b50\u7684\uff09\u3002\u5b9e\u4f8b\u5316\u4e86\u7c7b\u4ee5\u540e\u5c31\u662f\u8c03\u7528\u65b9\u6cd5\uff0c\u4e5f\u548c\u5b9e\u4f8b\u5316\u7c7b\u4e00\u6837\uff0c\u8981\u6709\u53c2\u6570\u7684\u4f20\u9012\u3002\u5f53\u7136\uff0c\u6700\u597d\u5f3a\u5236\u8f6c\u6362\u4e00\u4e0b\u7c7b\u578b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u679c\u7136\uff0c\u5728\u7f51\u4e0a\u67e5\u4e86\u4e00\u4e9b\u8d44\u6599\u4ee5\u540e\uff0c\u7ec8\u4e8e\u52a8\u6001\u52a0\u8f7d\u4e86dll\u5e76\u4e14\u8c03\u7528\u4e86\u91cc\u9762\u7684\u65b9\u6cd5\u3002\u5176\u5b9e\u641e\u61c2\u4e86\u4ee5\u540e\u8fd8\u662f\u5f88\u7b80\u5355\u7684\u3002\u5177\u4f53\u5b9e\u73b0\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[8],"class_list":["post-9","post","type-post","status-publish","format-standard","hentry","category-thinking-on-the-keyboard","tag-8"],"_links":{"self":[{"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongliangjie.com\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}