473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Visual Basic .Net IDE Add-In that adds a Web Reference or Normal Reference to Current Project

I already have a working Visual Basic .Net Add-in. It loads when the
IDE loads and there is a button to run it from the tools menu. It
also creates a tool window that can be docked anywhere on the screen.
It does a few things with web services, but my problem is that I need
the add-in to create a Web Reference to a project that is loaded in
the IDE. I found this code but I think it's only for Macros (I'm not
familiar with VB macros):

Imports EnvDTE
Imports System.Diagnostics
Imports VSLangProj

Public Module AddWebRefernceMacro
Sub AddWebReference()
Try
Dim applicationObjectWeb As EnvDTE.DTE
' This example assumes that the first project in the
solution is
' either a Visual Basic or C# project.

Dim aVSProject As VSProject =
CType(applicationObjectWeb.Solution.Projects.Item( 0).Object,
VSProject)

If (aVSProject.WebReferencesFolder Is Nothing) Then
Dim newFolder As ProjectItem
newFolder = aVSProject.CreateWebReferencesFolder()
' The new project item is a folder.
newFolder =
aVSProject.AddWebReference("http://someserver/webref")
' The new name of the folder appears in Solution
Explorer.
newFolder.Name = "Web References"
' The ProjectItems collection for the folder is not
empty.
MsgBox(newFolder.ProjectItems.Count.ToString())
End If

Catch ex As System.Exception
MsgBox("error adding web reference, message: " &
ex.Message, MsgBoxStyle.Critical, "error with adding web reference")

End Try

End Sub

End Module

Can this code be used in my VB.Net add-in code or does it have to be a
macro? I have tried using this code just as a macro and just in the
Add-In and I always get the same error: Object reference not set to an
instance of an object.

Thanks in advance.
Nov 21 '05 #1
0 1048

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John | last post by:
I have a problem, it's not with any code I have because... there is no code. When I run a blank visual basic 6 form, it opens up just fine. When I add a text box, a caption, and a button... it...
2
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
3
by: Omar | last post by:
Hi Developers, I am trying to access an Excel data file through a VB.Net application. I have the following code: =================================== VB.Net Code =================== Dim...
2
by: elnahrawi | last post by:
Download ebook http://books-download.com/?Book=1487-Visual+Basic+2005+Jumpstart Okay, all you VB6 developers--time's up. As of March 2005, Microsoft no longer supports this version of Visual...
1
by: Stewart | last post by:
Hi All, I have not yet seen Visual Studio 2005 and I could not collect much information on this. I just want to know whether Visual Stdio 2005 is enhanced Visual Studio ..net 2003 or is it...
1
by: nuoo | last post by:
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .NET Learn how to turn data into solutions with SQL Server 2000, Visual Basic .NET, and XML. Get a fundamental grasp of SQL...
0
by: czi02 | last post by:
Hi there;; I had design on frontapge Ive put pictures and hyperlink it. on it.. Then I want it to add on my visual absic 6.0. What is the properties or components am i going to usesd to be able...
11
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I have seen the terms Visual Basic 2005 and VB.NET. It seems that sometimes they seem to be referring to the same thing but sometimes they are not. I also run into terms like VB9 and VB10.
0
by: vacuit | last post by:
Visual Basic 2005 I want to save a copy of a datatable (that the user has changed) with a new name back to the database (Access) I have this code to save a copy with a new name to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.