|
-
Aug 20th, 2012, 09:38 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Type Expected although i import the namespace
hello guys just wanna ask why i it gives me an error of type expected although i import the namespace of the required class..
this is my code
Code:
dim request as HttpWebRequest = Directcast(WebRequest.Create(url),HttpWebRequest)
why it gives me an error in HttpWebRequest it said that type expected eventhough i Import System.net
i always need to complete the HttpWebRequest to this System.net.HttpWebRequest
I also try to add the System.net Reference using the taskbar.
-
Aug 20th, 2012, 09:55 AM
#2
Re: Type Expected although i import the namespace
Obviously the reference is useless because, as the documentation (which I'm sure you've read) states, the HttpWebRequest class is defined in the System.dll assembly, which you should find is referenced by default. If you have a reference to that assembly and you've imported the System.Net namespace then that should be all you need to do. Either something is broken or there's something you're not telling us. I'd be interested to see a screenshot of your code window showing that file. Can you attach one?
-
Aug 20th, 2012, 10:09 AM
#3
Thread Starter
Hyperactive Member
Re: Type Expected although i import the namespace
 Originally Posted by jmcilhinney
Obviously the reference is useless because, as the documentation (which I'm sure you've read) states, the HttpWebRequest class is defined in the System.dll assembly, which you should find is referenced by default. If you have a reference to that assembly and you've imported the System.Net namespace then that should be all you need to do. Either something is broken or there's something you're not telling us. I'd be interested to see a screenshot of your code window showing that file. Can you attach one?
thanks for the reply JM Yeah i read the documentation that's why i import the system.net
this is the screenshot the coding is not finish.
-
Aug 20th, 2012, 10:18 AM
#4
Re: Type Expected although i import the namespace
Right then, so what you weren't telling us is that your project is named HttpWebRequest. That means that the root namespace of your project is also named HttpWebRequest. When you type just that into your code, the compiler interprets it to be the root namespace of your project, not the class from the System.Net namespace. The logical thing to do is to give your projects proper names. In this case it could be something like "HttpWebRequest Demo" or "HttpWebRequest Test" if that's what the project is actually for. If it's a real project then give it a name that reflects its purpose, not what class it is using. For real projects it's also good to choose a "company name" and use that all the time. For instance, if I was creating a project that demonstrated using the HttpWebRequest class I might name it Wunnell.HttpWebRequestDemo.
In the short term, go into the project properties and change the root namespace to something other than the name of an existing type or else fully qualify that type in your code.
-
Aug 20th, 2012, 10:30 AM
#5
Thread Starter
Hyperactive Member
Re: Type Expected although i import the namespace
 Originally Posted by jmcilhinney
Right then, so what you weren't telling us is that your project is named HttpWebRequest. That means that the root namespace of your project is also named HttpWebRequest. When you type just that into your code, the compiler interprets it to be the root namespace of your project, not the class from the System.Net namespace. The logical thing to do is to give your projects proper names. In this case it could be something like "HttpWebRequest Demo" or "HttpWebRequest Test" if that's what the project is actually for. If it's a real project then give it a name that reflects its purpose, not what class it is using. For real projects it's also good to choose a "company name" and use that all the time. For instance, if I was creating a project that demonstrated using the HttpWebRequest class I might name it Wunnell.HttpWebRequestDemo.
In the short term, go into the project properties and change the root namespace to something other than the name of an existing type or else fully qualify that type in your code.
Thanks for the help JM i thought i have missing a code but it just the name of the project. thanks again now i have a new lesson learned
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|