VSTA With VB.Net / Help Please

Latest post 02-05-2008 12:20 PM by Melody. 19 replies.
  • 01-11-2008 9:50 PM

    VSTA With VB.Net / Help Please

    I am trying to add VSTA to a VB.Net app to allow users to write custom procedures based on application conditions. I would like to be able to add some code modules that would be exposed to the host application and vice versa.

    Thanks In Advance.

  • 01-12-2008 2:49 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    Wonderful!  If you would like a VB.Net sample, please check out ShapeAppVB (VSTA v 1).  It is available for download at http://www.summsoft.com/files/folders/vsta_samples/entry510.aspx

    Are you doing a VSTA v1 or v2 integration?  If you are using VSTA v 2, you will want to download the updated release.  To access the release, go to the VSTA 2.0 SDK CTP Now Available blog and follow the instructions.  If you have any questions or problems please let us know.

    Thanks!
    -Melody
  • 01-14-2008 1:44 PM In reply to

    Re: VSTA With VB.Net / Help Please

    Thanks for the help, i downloaded the updates but have not tested yet. i am curious though; can VSTA be launched from my application and be used to generate vb code without developing an "Add-in"? the integration seems tricky to me, hopefully i will have better luck with new updates.

    thanks

  • 01-14-2008 1:59 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    Great, I'm glad you got the updates.

    >>can VSTA be launched from my application and be used to generate vb code without developing an "Add-in"?

    The VSTA DTE will be associated with a host when it launches.  That turns "me" or "this" in the startup class into an instance of the entry point class of the host.  Beyond that you can really do what ever you want.  "Add-in's" are used to extend the host, macros are add-ins that perform operations (but do not extend) on the host- if you wanted to add some code that has nothing to do with the host that's fine.  

    >the integration seems tricky to me

    It can be a little intimidating at first but the documentation with this release is very good.  If you have any questions or problems don't hesitate to ask.

    Good luck!

    -Melody

  • 01-14-2008 2:10 PM In reply to

    Re: VSTA With VB.Net / Help Please

    Thanks for your help
  • 01-15-2008 11:53 AM In reply to

    Re: VSTA With VB.Net / Help Please

    Still struggling with this, I have created a empty class and added references for the following

    Microsoft.VisualStudio.Tools.Adapter.v9.0

    Microsoft.VisualStudio.Tools.Adapter.AddInManager

    Microsoft.VisualStudio.Tools.Adapter.DesignTime.v9.0

    EnvDTE

    envdte90

    I am not really sure which libraries i am supposed to be using. So i build my class and then run it through Proxygen.exe to create my decriptor.xml file. then i add a proxy project to my class solution and add the descriptor.xml file to the proxy project. I modify the descripter.xml file and set the [isaddinentrypoint="true"], i save the file and run in through proxygen.exe to create my proxy.cs file and then add it to my proxy project. Next i build my proxy project to produce my ProxyProject.dll; i register my HostID and add my new library to the GAC. finally when i run projectgen.exe on screen 2 when i reference my ProxyProject.dll i get an error that says it dosen't seem to be a valid proxy file or the insertion point class is missing.

    i have read through many of the documents and dont really see where i am going wrong. but i do have some questions.

    1. Can I use a blank class to create an add-in so that i may modify code and expose to and from the host app?
    2. Is VSTA 2.0 SDK supported with Visual Studio 2005 with all updated Frameworks 1, 2, 3 and 3.5?
    3. Which libraries should i reference with my class project and then with my proxy project?
    4. do i need to have VSTA SDK versions 1 and 2 installed?

    thanks for your patience and time.

     

  • 01-15-2008 1:33 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    bpreston,

    No problem- this was one of our first test cases. 

    There are a couple of things that may have caused this problem.  If you have VSTA v 1 installed you may be bringing up version 1 of ProxyGen or ProjectGen.  If you added the descriptor file to a project and then modified it, you may be running the original descriptor file instead of the updated version through ProxyGen.  Or, there could be another problem.

    Here's the steps I took to get an empty VB.Net class library working as a host (using Visual Studio 2005 with VSTA v 2 installed including the .Net 3.5 Framework).  If you follow these you should be okay.

    1)  Create and build an empty VB.net class library. 

    No need to add references here yet.  You'll need to add them during the integration if you want to load add-ins or show the DTE, but no references are need to expose the Object Model (OM).  To see which references you'll need and when, follow the ShapeApp Walkthrough or the associated sections in the SDK.

    2)  Use ProxyGen to create a descriptor file for the empty VB lib. (See Note 1)

    C:\Documents and Settings\Administrator>cd "C:\Program Files\Visual Studio Tools
     for Applications 2.0 SDK\2008.02\Visual Studio Tools For Applications\Tools\Pro
    xyGen\x86"

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProxyGen\x86>ProxyGen /l:"C:\EmptyVB_Lib\EmptyV
    B_Lib\bin\Debug\EmptyVB_Lib.dll" /o:"C:\EmptyVB_Lib\EmptyVB_Lib OM.xml" /f
    ProxyGen.exe : ProxyGen.exe [Version 9.0.21031.6]
    c Microsoft Corporation. All rights reserved.

    ProxyGen.exe Information: 0 : Note: All assemblies written in Visual Basic conta
    in automatically generated types that use generics and types that derive from ty
    pes in external assemblies. ProxyGen.exe does not support using these features i
    n an object model. You can ignore warnings that ProxyGen.exe displays about thes
    e unsupported features if the warnings refer to automatically generated types, r
    ather than types in your object model.


    ProxyGen.exe Information: 0 : Finished

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProxyGen\x86>

    3)  Edit the descriptor file created above, marking the empty class as isAddInEntryPoint="true" and save.

    <?xml version="1.0" encoding="utf-8"?>
    <Library originalName="EmptyVB_Lib" versionMajor="1" versionMinor="0" xmlns="http://schemas.microsoft.com/vsta/2008/01/ProxyGenDescriptor">
    <ManagedLibrary>
    <Class originalFullyQualifiedName="EmptyVB_Lib.Class1" isExcluded="false" isAddInEntryPoint="true" />
    </ManagedLibrary>
    </Library>

    4)  Use ProxyGen to create a proxy file using the updated descriptor file.  (See Note 1)

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProxyGen\x86>ProxyGen /i:"C:\EmptyVB_Lib\EmptyV
    B_Lib OM.xml" /c:"C:\EmptyVB_Lib\Proxy.cs" /f
    ProxyGen.exe : ProxyGen.exe [Version 9.0.21031.6]
    c Microsoft Corporation. All rights reserved.


    ProxyGen.exe Information: 0 : Finished

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProxyGen\x86>

    5)  Create a proxy project (EmptyVB_Lib_Proxy), add the proxy file created above.  The proxy should contain 3 classes:  the empty class from your VB project, the empty class appended with "EntryPoint", and a helper class.  If the empty class appended with "EntryPoint" class is not in the proxy the updated descriptor file was not used.  To compile and the following references (See Note 1): 

    Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0

     System.AddIn (version 3.5)

    6)  Sign the proxy assembly.  Copy the post build commands and InstallInGAC.bat and InstallForVB.bat files from any of the ShapeAppCSharpProxy sample projects including with the SDK.  The post build events are below.  Using these events and files ensures that the latest build of your proxy is always in the GAC and the VSTA pipeline.  Build the project to trigger the post build events.  (For more information see the Creating Proxies section of the SDK)

    call "$(ProjectDir)InstallInGac.bat" "$(TargetPath)"
    call "$(ProjectDir)InstallForVB.bat" "$(TargetPath)"

    7)  Register the host and run setup.  For more information see "How to:  Register the Host Application" in the SDK". (See Note 1)


    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSTAHostConfig\EmptyVB_Lib\2.0]
    "AppName"="EmptyVB_Lib"
    "ProjectTemplatesLocation"="C:\\EmptyVB_Lib\\Templates"
    "VSTAVersion"="9.0"

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProjectGen\x86>cd "C:\Program Files\Microsoft V
    isual Studio 9.0\Common7\IDE"

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>vsta /hostid EmptyVB_Li
    b /setup

    8)  Use ProjectGen to create a project template.  (See Note 1):

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProxyGen\x86> cd "C:\Program Files\Visual Studi
    o Tools for Applications 2.0 SDK\2008.02\Visual Studio Tools For Applications\To
    ols\ProjectGen\x86"

    C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02\Visual Stu
    dio Tools For Applications\Tools\ProjectGen\x86>ProjectGen

    ProjectGen should now work without any errors or warnings.

     

    > 1.  Can I use a blank class to create an add-in so that i may modify code and expose to and from the host app?

    Yes.  Using an "empty Object Model" is fine.  Keep in mind, if you change your object model and want the VSTA add-ins to see the changes you will have to regenerate the descriptor and proxy files.  The add-ins see the proxy not the host directly.

    >2)  Is VSTA 2.0 SDK supported with Visual Studio 2005 with all updated Frameworks 1, 2, 3 and 3.5?

    Note 1  Yes.  However, Visual Studio 2008 is strongly recommended.  One issue with using Visual Studio 2005 with VSTA v 2 is command prompts.  To be sure you are using the correct files, manually change the directories.  For more information, see Using VSTA v 2 with Visual Studio 2005

    > 3)  Which libraries should i reference with my class project and then with my proxy project?

    The proxy needs System.AddIn (version 3.5) and Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.  For the host this depends on what type of integration you are doing, see the walkthroughs in the SDK for more information on this.

    >4)  do i need to have VSTA SDK versions 1 and 2 installed?

    If you have both versions 1 and 2 installed (even if you uninstalled version 1) you may have problems with using the correct versions of vsta.exe, ProxyGen, and ProjectGen.  To avoid these issues, check that there are no VSTA v 1 environmental path variables set up and change directories manually when using a command prompt.

    I hope this helps!  If you have any other questions or issues please let me know.

    Thanks!

    -Melody

  • 01-15-2008 4:50 PM In reply to

    Re: VSTA With VB.Net / Help Please

    I have done everything to the letter and i still am having trouble.

    I didn't have any issues until the two .bat files execute. I get errors on Both, so i manually installed my ProxyProject Build ("Gacutil.exe /i "ProxyAssembly.dll /f") without any issues but the "InstallForVB.bat" file still returns errors.

    C:\>"C:\WINDOWS\Microsoft.NET\Framework\v3.5\AddInUtil" -PipelineRoot:"C:\Progra
    m Files\Common Files\microsoft shared\VSTA\Pipeline" -Rebuild
    Warning: Add-in Adapter Microsoft.VisualStudio.Tools.Applications.AddInAdapter,
    Microsoft.VisualStudio.Tools.Applications.AddInAdapter.v9.0, Version=9.0.0.0, Cu
    lture=neutral, PublicKeyToken=b03f5f7f11d50a3a defines a constructor that doesn'
    t take one parameter.  This constructor can't be used in the add-in model.

    And when i run "ProjectGen.exe" i still get a error message when i select my Proxy.dll

    Thanks

     

  • 01-15-2008 7:47 PM In reply to

    Re: VSTA With VB.Net / Help Please

    Melody,

    Allright so i have no hair left by the time i successfully created my first VSTA Add-in project but just when i think i'm on a roll i try to open a new project with VSTA 2.0 IDE and i get an error message. "ERROR HRESULT E_FAIL has been returned from a call to a COM component". Any Ideas, I have to think I'm getting pretty close hear.

    Thanks Again

  • 01-15-2008 9:29 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    bpreston,

    >I didn't have any issues until the two .bat files execute. I get errors on Both

    Opps!  I forgot to mention that the VSTA v 2 InstallInGAC.bat file doesn't always work with Visual Studio 2005.  Edit the file to use the Visual Studuio 2005 gacutil tool (delete everything and use the code below).  If you are still getting an error please send the error detail.

    SET TARGET=%1

    "%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil" /i %TARGET%

    >Warning: Add-in Adapter Microsoft.VisualStudio.Tools.Applications.AddInAdapter,
    Microsoft.VisualStudio.Tools.Applications.AddInAdapter.v9.0, Version=9.0.0.0, Cu
    lture=neutral, PublicKeyToken=b03f5f7f11d50a3a defines a constructor that doesn'
    t take one parameter.  This constructor can't be used in the add-in model.

    The warning you're getting when you run InstallForVB.bat can be ignored, that is a known issue and it shouldn't affect anything.

    >i successfully created my first VSTA Add-in project

    I'm glad you were able to create a project template!  If you were able to get that far, your in good shape. 

    >i try to open a new project with VSTA 2.0 IDE and i get an error message. "ERROR HRESULT E_FAIL has been returned from a call to a COM component".

    Double check that you using the updated release (C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.02)- this error was seen with the CTP release (C:\Program Files\Visual Studio Tools for Applications 2.0 SDK\2008.01).  Just to be on the safe side, I would go ahead and uninstall the CTP and updated releases (and delete %Program Filest%\Visual Studio Tools for Applications 2.0 SDK), then re-install the updated release. 

    If you are still getting this problem, try my working sample EmptyVB_Lib in Visual Studio 2005 with VSTA v 2 (updated release) to see what happens with that. 

    You're so close, I'm sure we can get you up in running soon!
    -Melody


  • 01-16-2008 12:48 PM In reply to

    Re: VSTA With VB.Net / Help Please

    Melody,

    I uninstalled VSTA, deleted assosiated folders then reinstalled. I still get the error when i try to open a new project with my template, "ERROR HRESULT E_FAIL has been returned from a call to a COM component".
    I also get a error log of-

    Event Type: Warning
    Event Source: Visual Studio - VsTemplate
    Event Category: None
    Event ID: 1
    Date:  1/16/2008
    Time:  12:18:22 PM
    User:  N/A
    Computer: BP-LAPTOP
    Description:
    The Visual Studio template information is out of date. Regenerate the templates by running 'vsta.exe /installvstemplates' or reinstalling Visual Studio.  Note: corrective action requires Administrator privileges.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    I have not tried your addin yet but currently working on it.

    thanks,

    bpreston

     

  • 01-16-2008 2:37 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    bpreston,

    There are issues with VS templates in VSTA, however, those issues involve warnings and VS templates with wrong names/icons that don't work.  We haven't seen this prevent VSTA from opening a VSTA template- if this is a bug I want to get it reported ASAP but we'll have to reproduce it first.

    Please let me know what happens with the sample.  If you have the same problem with that one then we need to look at the template locations. 

    Also, just to be sure- please confirm this is how you are creating and opening templates.  If this is what you are doing, when does the error show up?

    1)  Create a "bare bones" project template with ProjectGen (for empty vb 05 host or use the one I sent).  Just the basics- no icons, icon image list, host icon index, host item icon index, host item open folder icon index,  additional refs, debug command line, or In-Process Host.

    2)  On the 4th and final screen of ProjectGen, check "Create project template", "Register template with host application" and "Save project template descriptor file".  The location to create the template should be auto-populated with the ProjectTemplatesLocation you specified in the registry (if not let me know).

    3)  After completing ProjectGen, open a command prompt, change directories and run the "vsta /hostID <hostID>" command as below

    C:\Program Files\Microsoft Visual Studio 9.0\VC>cd "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE"

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>vsta /hostid EmptyVB_Lib

    4)  Once the VSTA DTE opens, you select File then New Project. 

    5)  In the New Project window templates are listed.  Select the one created above.


    Next Step:  template locations.  In addition to the location specified in the ProjectTemplatesLocation, here are the locations your templates should be (it may be easier to search for the template name).  If your templates are not located here, please let me know where they are. 

    C:\Documents and Settings\All Users\Application Data\Microsoft\VSTAHost\<HostID>\9.0\ProjectTemplatesCache\CSharp\1033

    C:\Documents and Settings\All Users\Application Data\Microsoft\VSTAHost\<HostID>\9.0\ProjectTemplatesCache\VisualBasic\1033

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\<HostID>\1033

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\VisualBasic\<HostID>\1033

     

    The only other thing I can think to check is you VS05 templates.  They should be somewhere like C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates.  If there's anything there (including VSTa templates) please let me know.

    :)

    -Melody

  • 01-17-2008 11:36 AM In reply to

    Re: VSTA With VB.Net / Help Please

    Melody,

    Allright, so I think I found were I was going wrong. When I was opening Vsta.exe from the command prompt, I was opening through explorer.

    When I run "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>vsta /hostid EmptyVB_Lib" from command window I can then create a new project with your template as well as the one that I created.

    Niether templates work when Vsta.exe is executed from explorer. Is this behaivior expected?

    Thanks again for your help, your support is excellent. I will test this with my application and see how it goes.

     

    bpreston

  • 01-17-2008 12:41 PM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 242

    Re: VSTA With VB.Net / Help Please

    bpreston,

         When you open vsta.exe through the explorer (at C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) it is not associated with a host; therefore, it doesn't know which templates to load.  VSTA is trying to grabbing VS templates (known issue- expected behavior but bad) and is throwing the exception because of what it does or doesn't find.  When I try open vsta.exe through the explorer I get a similar warning, but not the COM exception. 

        This does not mean that the VSTA DTE always has to be opened from the command prompt.  In the VSTA v 1 samples, a ShapeAppAdvancedCSharpSetup project is included which creates a setup.exe file that installs a shortcut "ShapeAppCSharp in VSTA" which when launched associates the VSTA DTE with the ShapeAppCSharp host.  The VSTA v 2 pre-RTM samples do no include this, but I expect the RTM samples will.

    Good luck and thank you!

    -Melody

  • 01-17-2008 6:38 PM In reply to

    Re: VSTA With VB.Net / Help Please

    Melody,

    I was wondering if you might have a VB 2005 sample to demonstrate exposing objects between my application and the VSTA 2.0 Addin? I have been able to open the VSTA IDE from a class in my application but I dont understand all that is involved to bring them together.

    Most of the samples on your site are in C#, I can somewhat follow them but some of the syntax is foreign to me.

    Thanks

    Brian

Page 1 of 2 (20 items) 1 2 Next > | RSS
Copyright Summit Software Company, 2008. All rights reserved.