如何獲得COM的Interop互動庫C#原始碼
如何獲得COM的Interop互動庫的原始碼
How can I generate C# source code for a COM Interoplibrary instead of an assembly?
Whenimporting a COM library (either directly with tlbimp, or indirectly with visualstudio add reference dialog,) is there a way to generate C# source code insteadof a binary interop assembly, like Interop.Word.dll, for example?
UPD:Reflector is bad idea. Problem is that for the com interface is not only asignature, but the order of the members. Reflector this order is violated
在匯入一個COM庫(與tlbimp直接或間接與visual
studio新增引用對話方塊中,)有辦法生成c#原始碼,而不是二進位制互操作組裝,像Interop.Word。例如,dll呢?
更新:反射器是壞主意。問題是,com介面不僅是一個簽名,但成員的順序。反射器這是違反規則。
I would go aheadand generate the interop assembly using TLBIMP, and the use Reflector to disassemble it. The interop assembly has noactual implementation code, as you will see. You can then just copy and pastethe code (or the CoClasses and interfaces you need) into a new .cs file in yourproject.
我會繼續使用TLBIMP生成互動操作組裝,拆卸和使用反射器。互操作組裝沒有實際實現的程式碼,您將看到。你可以複製和貼上的程式碼(或者你需要的輔助類和介面)到一個新的。cs檔案在您的專案。
Youcannot generate C# directly, but if your real problem is that you have a needto tweak the interop library then you might have better luck using the CLRInterop team's custom TLBIMP tool on codeplex - it's pretty flexible and youhave full source [to it.]
http://clrinterop.codeplex.com/releases/view/17579
Update:If you're really trying avoid shipping binaries, then you could feasiblyintegrate the above tool (in source format) into your project so that yougenerate this interop library at runtime. Result? No binaries toship.
你不能直接生成c#,但如果你的真正的問題是,你需要調整互動操作庫,那麼你可能會有更好的運氣使用CLR互操作團隊的定義TLBIMP工具在codeplex上——很靈活,你有完整的原始碼(。)
http://clrinterop.codeplex.com/releases/view/17579
更新:如果你真的想避免航運二進位制檔案,然後你能輕鬆將上面的工具(在源格式)整合到你的專案,這樣你生成這個互操作在執行時庫。結果呢?船沒有二進位制檔案。
In general it cannot be done. C# does notsupport all possible constructs needed to create a working interop assembly.You cannot add e.g. attributes to return types or method parameters in C#although they are needed sometimes to help the marshaller to correctlytranslate some C++ types.
Yours, Alois Kruas
一般情況下它不能被完成。c#不支援所有可能的結構需要建立一個工作互操作程式集。你不能新增如屬性返回型別或方法引數在c#中雖然他們有時需要幫助marshaller正確翻譯一些c++型別。
你的,阿洛伊斯Kruas
How do I generate COM interop proxies into C# source code?
我如何生成COM互操作代理到c#原始碼嗎?
Take a look at the following MSDN article:
How to: Create Wrappers Manually (Talks about how to createyour interop assembly manually.):
http://msdn.microsoft.com/en-us/library/x8fbsf00.aspx
Once you've got the interop assembly, use a toollike Reflector to disassemble it and generate the raw C#source. Reflector.FileDisassembler makes this really easy.
http://www.denisbauer.com/NETTools/FileDisassembler.aspx
Now you can include the generated C#/VB sources directly into yourassembly.
看看下面的MSDN文章:
如何:建立包裝器手動(討論如何建立你的互操作手動裝配。)
一旦你得到了互操作組裝,使用反射器等工具拆卸並生成原始c#源。反射器。FileDisassembler使這一切變得簡單。
現在你可以包括生成c# / VB來源直接進入您的程式集。
I do not know simplerway, and extract interface descriptions via Reflector. However in VS 2010Microsoft will do this for you automatically.
我不知道更簡單的方式,通過反射器和提取介面描述。然而在VS 2010微軟將自動為您做到這一點。
反編譯工具Reflector下載(整合FileGenerator和FileDisassembler)
Reflector是一款比較強大的反編譯工具,相信很多朋友都用過它,但reflector本身有很多侷限性,比如只能一個一個的檢視方法等,但幸好reflector支援外掛功能目前網上有很多reflector的外掛,本人找取了兩個應用範圍很廣,並且廣受好評的外掛:Reflector.FileDisassembler和Reflector.FileGenerator和Reflector進行了整合,放在了一個壓縮包中,大家可以直接解壓縮後就開始使用,其中FileGenerator在網上沒有現成dll,本人編譯後將其取出,放在了壓縮包中,一直在苦苦找尋的朋友這次可以拿來直接用了:)
點選下載Reflector整合壓縮包
本壓縮包中Reflector.exe已經升級為最新的5.0版本,具體的使用方法不多說了,只簡單介紹一下本壓縮包的使用步驟:
先下載本壓縮包並解壓縮,執行其中的Reflector.exe(主程式),初次執行會彈出錯誤提示對話方塊,因為引用的兩個外掛DLL是按照我本地實際情況配置的,所以你還需要根據你的實際情況來從新配置一下,方法很簡單,我們拿引用FileGenerator.dll來做一個範例,
首先介紹一下Filegenerator,FileGenerator外掛的作用是:根據dll檔案,把裡面的原始檔匯出成檔案,匯出來的檔案除了沒有註釋,變數名也變了,其它的可謂是沒有差別。對於一些比較好的控制元件,如果不是開源的,完全可以匯出成檔案,然後自己加上註釋,少許修改,很好的利用起來。(不開源的dll,用起來也不放心啊)
具體的初始化設定方法:點選View->Add-Ins...,彈出一個視窗,然後點選Add->選擇資料夾裡面的:"FileGenerator.dll",點選close.
然後回到Reflector視窗,Tool->Generator File(s)... 右邊就出現了外掛的視窗,選中左邊的dll檔案,點選右邊的匯出檔案,原始碼就全部匯出來了!
另一個外掛Reflector.FileDisassembler.dll設定方法也和這個一樣。
另外再提供一些Reflector的相關外掛下載:
Reflector.FileDisassembler |
Reflector.CodeMetrics |
Reflector.SQL2005Browser |
Reflector.DelphiLanguage |
Reflector.McppLanguage |
Reflector.ChromeLanguage |
Reflector.Diff |
Reflector.VisualStudio |
Reflector.ClassView |
Reflector.CodeModelView |
Reflector.FileGenerator |
Reflector.Graph |
Reflector.OpenRunningAssembly |
來源:http://daiwen.blog.ccidnet.com/blog-htm-do-showone-uid-55708-type-blog-itemid-194608.html
作者: XuGang 網名:鋼鋼 |
宣告: 本文版權歸作者和部落格園共有。轉載時必須保留此段宣告,且在文章頁面明顯位置給出原文連線地址! |
Takea look at the following MSDN article:
· How to: Create WrappersManually (Talks abouthow to create your interop assembly manually.)
Once you've got the interop assembly, use a tool like Reflector to disassemble it and generate the rawC# source. Reflector.FileDisassembler makesthis really easy.
Now you caninclude the generated C#/VB sources directly into your assembly.
http://blog.csdn.net/nuaalfm/article/details/2089149
FileDisassembler是Reflector 的一個外掛,老外做的東西還真好用
.NET Reflector 下載地址(現在的最新版本是5.0.50.0)
http://www.aisto.com/roeder/dotnet
或者
http://www.aisto.com/roeder/dotnet/Download.aspx?File=Reflector
FileDisassembler 下載地址
http://www.denisbauer.com/Downloads/Reflector.FileDisassembler.zip
或者從以下地址下載
http://dl2.csdn.net/down4/20080111/11113854907.rar
使用方法
開啟 Reflector ,在 view選單下的 Add-Ins,將 Reflector.FileDisassembler.dll 新增到裡面。然後載入一個需要反編譯的dll檔案,選中,然後選擇 Tools-File Disassembler 開啟右側 File Disassembler 視窗,點選 Generate 按鈕就ok啦。
我試了一下,還真是不錯,連工程檔案都生成了!
特別說明:
NET Reflector是是收費的,但是外掛是開源的,下載地址為:http://reflectoraddins.codeplex.com/
相關文章
- C#操作Microsoft.Office.Interop.Word類庫完整例子C#ROS
- C#獲取HTML原始碼C#HTML原始碼
- “沉浸式互動”讓遊戲變得更加迷人,玩家能更深層次的獲得快感遊戲
- .net post提交和獲得html頁面的原始碼HTML原始碼
- 教育原始碼的重要任務——做好直播互動原始碼
- containerd 原始碼分析:kubelet 和 containerd 互動AI原始碼
- ArcGIS如何自動獲得隨機取樣點?隨機
- C#裡面獲得應用程式的當前路徑C#
- C#與Python互動方式C#Python
- 如何使用程式碼獲得一個function module的Where Used ListFunction
- 如何在TypeScript程式碼裡獲得HTML元素的css屬性TypeScriptHTMLCSS
- .NET C#基礎(7):介面 - 人如何和貓互動C#
- SmartRules讓MindManager的互動圖變得更加智慧
- 如何獲得一個Oracle 23ai資料庫(docker容器)OracleAI資料庫Docker
- RiverbedSteelConnect榮獲2017Interop東京展“最佳展示獎”
- 動態IP代理-如何讓文章獲得高閱讀量?
- 百度的信任SEO該如何獲得
- sal原始碼解析-輕量級的滾動動畫庫原始碼動畫
- 短視訊系統原始碼,讓程式獲得通知欄許可權原始碼
- 抖音互關原始碼 E4A原始碼含資料庫後臺程式搭建可用原始碼資料庫
- 獲得資料庫操作日誌的三種方式資料庫
- [從原始碼學設計]螞蟻金服SOFARegistry 之 如何與Meta Server互動原始碼Server
- 【大型軟體開發】淺談大型Qt軟體開發(三)QtActive Server如何透過COM口傳遞自定義結構體?如何透過一個COM口來獲得所有COM介面?QTServer結構體
- 如何從 dump 檔案中提取出 C# 原始碼?C#原始碼
- 如何獲得CSDN下載積分
- 軟體測試如何獲得高薪?高薪
- 如何獲得PMP認證證書
- 深入解析C# List<T>的原始碼C#原始碼
- 使用c# 開發 php的com元件C#PHP元件
- 自動化成本高?那麼如何獲得最高的投資回報呢?
- office 互動庫 Apache POIApache
- 如何寫出有效的 Prompt,獲得更好的 ChatGPT 回覆ChatGPT
- 從原始碼分析DEARGUI之互動新增和刪除元件原始碼GUI元件
- 【原始碼】RocketMQ如何實現獲取指定訊息原始碼MQ
- 獲取AOSP原始碼原始碼
- 互站網48元買的小說程式原始碼 自動採集原始碼
- C# 簡單的學生資訊管理系統,好看的UI介面,與資料庫互動C#UI資料庫
- 如何獲取微信的版本號詳解【附完整原始碼】原始碼
- SAP Data Intelligence API如何獲得Access TokenIntelAPI