I have to convert a C# project to VB.NET and VBA. It's a console app that uses the Microsoft Office API (Microsoft.Office.Interop.*
).
My two questions:
- C# -> VB.NET: .NET Reflector is a good tool f开发者_StackOverflow社区or this, except that it doesn't preserve source code comments. Is there a way to do this?
- .NET -> VBA: is there an automated tool to do this conversion? It would need to be a client side tool (because the code is proprietary).
The best conversion seems to be done by SharpDevelop. Open your project and from the tools menu and select convert code to. Since it has all of your c# source code it does a very good job.
There are many ways to convert C# to VB.Net; for example, try Developer Fusion.
It is not possible to automatically convert C# to VBA because the environment, language, and libraries are radically different. However, you could expose the C# code as a COM server and call it from a thin wrapper in VBA.
Answer for question #1:
You cannot use Reflector to preserve source code comments because Reflector is disassembling the compiled code, which has had all comments removed.
Consider using a commercial tool like InstantVB, which will converts C# source code into VB source code (including comments): http://tangiblesoftwaresolutions.com/Product_Details/Instant_VB.html
You could convert the C# source code to VB.Net manually with this:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
which will preserve comments. As far as automatically converting C# to VBA or VB6, I'd be willing to say that that is almost certainly going to be completely impossible. There are many aspects of C#/.Net that are not available in VBA or VB6 (like inheritance, for one).
精彩评论