Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

C# vs VB Confusion

  Asked By: Carolyn    Date: Jan 28    Category: Sharepoint    Views: 852

The MSDN example for writing SharePoint Web Services is here:

msdn.microsoft.com/.../en-
us/odc_sp2003_ta/html/odc_writingcustomwebservicesforsppt.asp

And I'm at the point where I'm trying to code the button to execute
the "Hello World" service and it's written in C#

And, of course, I've gotten this far in VB

The code looks like this in C#

WSSServer.Service1 _svc = new WSSServer.Service1();
//to use the following line use System.Net in the using section
_svc.Credentials = CredentialCache.DefaultCredentials;
string _Retval = _svc.HelloWorld();
MessageBox.Show(_Retval);

Any chance any of you guys could return the same code in VB?

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Christop Mcfadden     Answered On: Jan 28

Try this, it's usually pretty accurate:
carlosag.net/Tools/CodeTranslator/Default.aspx

Or you can try the Visual Studio Add-In "Paste As VB":
msdn.microsoft.com/msdnmag/issues/06/02/PasteAs/

 
Answer #2    Answered By: Harshita Padwal     Answered On: Jan 28

Visual Studio is having trouble with the first line:

WSSServer.Service1 _svc = new WSSServer.Service1();

It doesn't like the WSSServer object. It says:

Error 1: The type or namespace name 'WSSServer' could not be found
(are you missing a using directive or an assembly reference?)

 
Answer #3    Answered By: Jennifer Jones     Answered On: Jan 28

Unless I'm mistaken, which is entirely possible, WSServer refers to your VB.NET web  service's default namespace... Perhaps you named your VB.NET project WSServer?

To my knowledge, there is no class in the Microsoft.SharePoint namespace named WSServer.

 
Answer #4    Answered By: Annie Norris     Answered On: Jan 28

Any ides what msdn  is trying to make me do?

I'm on this page about 2/3 of the way down:

msdn.microsoft.com/.../en-
us/odc_sp2003_ta/html/odc_writingcustomwebservicesforsppt.asp

The heading is "Using the web  service"

Is it just me or could a "hello world" demo be a little less
difficult?

 
Answer #5    Answered By: Kalyan Pujari     Answered On: Jan 28

This describes how to reference the web  service you created in the previous step, you'll need to substitute your server/project names for what they used in their demo to match what you created.

To use the custom Web Service

On another computer, open Visual Studio .NET.
On the File menu, point  to New, and then click Project.
In the Project Types box, select Visual Basic Projects or Visual C Projects, depending on which language you prefer.
In the Templates box, select Windows Application.
Specify a name and path for the project, and then click OK.
On the default form, add a command button  to invoke the new Web service.
Add a Web reference to the Web service:
Right-click the project, and then click Add Web Reference.
In the wizard, type the following URL, and then click Open to download the service  contract for the Web service:
http://Server_name/_vti_bin/Service1.asmx
Name this reference WSSServer.

This WSSServer is the object reference (web service reference) that you are missing in your client code  that accesses it.

 
Answer #6    Answered By: Cheryl Kelley     Answered On: Jan 28

Exactly. I had butchered the web  reference in my third try before I
realized I had a typo in the web method.

 
Didn't find what you were looking for? Find more on C# vs VB Confusion Or get search suggestion and latest updates.




Tagged: