WebServices through VC.Net

H

Hamed

Dear Sir/Madam

I should call web sevice from VC.Net,
The problem is when i want to create NetworkCredential object.
because that's undefined.
Please do me a Favore and tell me how can i do this.

because NetworkCredential defined in System.net,

Regards,
 
T

Tomas Restrepo \(MVP\)

Hamed,
I should call web sevice from VC.Net,
The problem is when i want to create NetworkCredential object.
because that's undefined.
Please do me a Favore and tell me how can i do this.

because NetworkCredential defined in System.net,

Did you add
#using <System.dll>

to your .cpp file?
 
H

Hamed

Thank you,
But when I Try to use NetworkCredential in VC.Net I get this error.

Code:
NetworkCredential* myCredentials = new NetworkCredential("user", "pass");


Error:
error C2065: 'NetworkCredential' : undeclared identifier

and in C# just add this line of code using system.net;
But in VC.Net I dont know what should I do.
I added #using<system.dll> bu still that error occures.

Please let me know,
Thanks in advance.
 
T

Tomas Restrepo \(MVP\)

Hamed,
But when I Try to use NetworkCredential in VC.Net I get this error.

Code:
NetworkCredential* myCredentials = new NetworkCredential("user", "pass");


Error:
error C2065: 'NetworkCredential' : undeclared identifier

and in C# just add this line of code using system.net;
But in VC.Net I dont know what should I do.
I added #using<system.dll> bu still that error occures.

Well, you're not considering the namespace it is in. Either qualify the
name, or add a
using namespace System::Net;
 
H

Hamed

Thanks alot,
I Set the option in compiler to /clr
#using <system.dll>
#using <mscorlib.dll>
using namespace System::Net;
in .cpp file

Ok now class in defined,
But there is a new error on this line:
NetworkCredential* myCredentials = new NetworkCredential("user", "pass");

ERROR:
error C3828: 'System::Net::NetworkCredential': placement arguments not
allowed while creating instances of managed classes


Regards & thanks in advance.
------------------------------
 
T

Tomas Restrepo \(MVP\)

Hamed,
I Set the option in compiler to /clr
#using <system.dll>
#using <mscorlib.dll>
using namespace System::Net;
in .cpp file

Ok now class in defined,
But there is a new error on this line:
NetworkCredential* myCredentials = new NetworkCredential("user", "pass");

ERROR:
error C3828: 'System::Net::NetworkCredential': placement arguments not
allowed while creating instances of managed classes

Something else must be causing the error because that line you just posted
compiles just fine for me. Can you show us the exact code? (including some
before and following context lines)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top