Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4046508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:34:20+00:00 2026-05-20T13:34:20+00:00

In a Visual Studio Add-In that successfully creates a form, but gives me no

  • 0

In a Visual Studio Add-In that successfully creates a form, but gives me no reference back to the EnvDTE’s prjItem instance.

Here’s the piece of code that adds the form to the project:

string templatePath = solution.GetProjectItemTemplate("Form.zip", "csproj");
ProjectItem prjItem = project.ProjectItems.AddFromTemplate(templatePath, "myForm.cs");

Obs.: ‘solution’ is an EnvDTE80.Solution2 object.

Of cource I can get the reference by other ways, like proj.ProjectItems.Item([index]) (doing a loop and checking for names), but that’s not how I want to do it, and I need this reference in orther to add controls to this form.

Am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:34:20+00:00Added an answer on May 20, 2026 at 1:34 pm

    Just found a comment on MSDN:

    AddFromTemplate always returns a NULL
    value

    At one time, this was true. But
    with later versions of Visual Studio,
    which included the ability to add
    multiple items from a single template,
    the return value for this method could
    not return multiple items. So it now
    returns a NULL value in all instances.
    This is due to the contraint that the
    COM signature for this particular
    method cannot be changed without
    breaking a lot of code already in use.

    Consequently, if you need the
    ProjectItem interface of the item just
    added via the AddFromTemplate call,
    you can either iterate through the
    ProjectItems collection, or you can
    create a ProjectItemsEvents.ItemAdded
    event just before calling
    AddFromTemplate, and store away the
    ProjectItem passed to your OnItemAdded
    handler.

    http://msdn.microsoft.com/en-us/library/envdte.projectitems.addfromtemplate(v=vs.80).aspx#1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any Visual Studio add-on (or windows/unix stand-alone program) that creates stub implementations
Is there any Visual Studio Add-In that can do the remove method refactoring? Suppose
Anyone knows any free Visual Studio add-in that would find and/or delete dead (unused)
I am looking for a Visual Studio add-in that would analyze the text around
We had the Power Commands for Visual Studio 2008 that add a context menu
I want to write an Add-In for Visual Studio that provides instant search for
I like the Add Connection or SQL Connection dialog that is in Visual Studio
Do you know if there is any add-in for Visual Studio, that shows the
I'm working on a visual studio 2008 add-in that will generate data-access code by
I'm working on a Visual Studio Add-in for Visual Studio 2008 that display a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.