Re: VSTA With VB.Net / Help Please

  •  01-15-2008, 1:33 PM

    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

View Complete Thread