junwei's profileRichard's footprint on ....PhotosBlogListsMore Tools Help

Blog


    February 24

    A Wonderful Intro to COM Interop

    The above links to a MSDN magazine article in which interaction in either direction from managed to native code are talked about. Addtionally, using SOS to debug program can be found there and I think it could be of much help.
     
     
    February 16

    Begin Yesterday's Plan

    This afternoon I played a while with COM interop since I was determined to do some research.
    After practising the interop sample from MSDN, as a novice, I grabed several fundamental concepts on it and began to know the skeleton of how to use a COM coponent from managed code.
    Type library is a basic concept in COM world and it contains data type definition whereas the assembly metadata is widely employed in managed environment. So you should make a bridge between them such that they can communicate with each other. You can use tlbimp.exe command tool to complete converstion from type library to interop assembly metadata. Then you can use the wrapper class to communicate with wrapped COM component in your managed code as you do with other managed classes.
    Here is a good article which briefly introduced history of COM and gave a good discussion on interop.
     
    COM Interop Exposed
    February 15

    Plan to Interop

    These few days I've been tangled with a problem. That's about our using WebBrowser control in our windows form. I can't prevent a information bar from poping up when running our proxy generator add-in. Afer searching it using goole and reading posts on MSDN forums, got little useful info. So frustrated. Following Sheng Jiang's advice, I was lead to I.E. development. There it is said that you can programatically control whether the information bar will pop up or not. I am shamed cause of that's all interfaces description with VC++ and I don't know how to do the equivelant using C#. That recall me of Interop issue a few days ago I met. How to invoke a c++ .dll from .net assembly and vice versas. Now chance is coming. I have got a few days free, I can delve into these concepts and do some more deeper research.
    Tomorrow I will begin with how to invoke C++ COM from .net assembly. I don't need to grab everything about COM,It will be enough for me to clerify what COM is and how to interop with it in the .net world from a C# developer's perspective. I think the successive articles will be about it. It's time to dive into them.
    February 11

    Frustrating Experience from FileCodeModel

    I met this problem first time since I work with VS2005 extensibility features. I have to say that's so frustrating experience.
    I used the FileCodeModel class to retrieve the hirarchical representation of the code file. It worked well with .cs code files as it was expected. Once I use in this way against .vb code file, however, It won't work. If you use this syntax to try to get the hirarchical code model:
    ProjectItem pi = proj.ProjectItems.Item("Test.vb");
    FileCodeModel fcm = pi.FileCodeModel;
    It only return null reference rather than not what you expected. I am not sure whether I use this class incorrectly or not.
    It's said in MSDN that as to c# or vb language, the code model is identical with slightly differences. I searched this with google. A lot of links indicated that it will be ok regardless your language kind. So I am confused.
    At present, a work around this I am using is to use TextSelection class to modify my .vb source code files rather than to use FileCodeModel. It works well although It seems alike VBA. The following snippet illustrates this:
    TextSelection txtSel = pi.Document.Selection;
    txtSel.StartOfDocument();
    //at the first, I passed the vsFindOptions.vsFindOptionsFromStart enum, it won't work.
    if(txtSel.FindPattern("Me.Url",vsFindOptions.vsFindOptionsNone)) 
    {
     txtSel.LineDown(false,1);
     txtSel.Text="what you want to place here!";
     pi.Save(pi.Name);
    }
    of cource, you must consider the code text alignment issue.
    There is a trick I must note is if you write your add-in using c# language, that you must pass the FindText or FindPattern method a second order parameter using vsFindOptionsNone, otherwise you won't get what you want. You don't have to do that with vb language because of optional parameter feature.
     
    February 03

    The FileMonitor tool

          Last Friday, we deployed our proxy generator add-in for VS2005. Unfortunately, this add-in can't work on some computer. after its installation, starting your IDE, it won't be listed in Add-in Manager. After searching through goolgle and MS extensibility forum. It seems I've got some clues.
          In these posts, a disk location was mentioned for storage addin loding info. Typically it's under your Application Data directory. I'll check it next Monday. During my search, I found this tool, FileMonitor, a tool which can monitor disk/file activities when you do some operations. It's said that can be of help to diagnose why the addin couldn't load. try it.
          The official site is: http://forum.sysinternals.com you can follow this link for details.
          Here is the download page: http://www.microsoft.com/technet/sysinternals/FileAndDisk/Filemon.mspx