473,587 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Diagnost ics
Imports VSLangProj

Public Module AddWebRefernceM acro
Sub AddWebReference ()
Try
Dim applicationObje ctWeb 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(applicati onObjectWeb.Sol ution.Projects. Item(0).Object,
VSProject)

If (aVSProject.Web ReferencesFolde r Is Nothing) Then
Dim newFolder As ProjectItem
newFolder = aVSProject.Crea teWebReferences Folder()
' The new project item is a folder.
newFolder =
aVSProject.AddW ebReference("ht tp://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(newFolde r.ProjectItems. Count.ToString( ))
End If

Catch ex As System.Exceptio n
MsgBox("error adding web reference, message: " &
ex.Message, MsgBoxStyle.Cri tical, "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 1057

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

Similar topics

10
4360
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 gives me an error from microsoft's error report and asks me to send or not send the error, i chose and then it quits. The error report won't let me copy the data, but i gather it's pretty useless information unless you have the source code to visual...
2
4222
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 Visual Basic.Net as a springboard for studying VBA. I use Office 2000 and would like to use VBA as a tool to customize it. I have zero programming experience. I would like to read through and work on the examples of a beginners
3
2953
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 sSqlString = "" Dim rCount As Integer = 0 Dim sDataSet As New DataSet() sSqlString = "Select * From "
2
1497
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 Basic. And you can't blame them. Three years ago, they introduced the .NET Framework--an elegant, powerful platform--along with the new component-based VB.NET language. But roughly five million of you decided to stick with VB6, mostly to maintain...
1
1117
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 Enhanced Visual Studio with Visual Basic 6.0. Is it ..net or the traditional Visual Basic 6.0 + with added features. Thanks.
1
1890
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 Server 2000 data access, data manipulation, and data definition T-SQL programming techniques, Visual Basic .NET language enhancements, Microsoft Visual Studio .NET integrated development environment advances, and the state-of-the-art technologies of...
0
874
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 to conect my frontpage to visual basic 6.0 For example;;;;; I had a form like this;;
11
2281
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
1533
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 dataset...how do I then update the database (without changing the original datatable)? Essentially I want to add a new datatable to the database. Dim dt As New DataTable dt = MyDataSet.OriginalDataTable.Copy dt.TableName = mytextbox.text...
0
8219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.