I had the same problem and looked for it for a long time!
I tried a lot of things including the following:
None of those worked for me. After some searching, testing and cursing, I finally found the problem: The application (webservice) was incorrectly hosted.
Let me explain with a little background:
I had a project containing two solutions: One solution was the website that I made (html, javascript, etc), the other solution contained a folder with the business logic, the database model and the webservices. Obviously the webservices folder contained my .asmx files and code-behind for them.
- Project
- Data Core
- Database Model
- Business Logic
- Webservices
- Website
I was hosting these in the following way:
- My website was hosted as a new site with the website folder as root folder
- My webservices I was hosting as an application in my website, with the webservices folder as root
More visually:
- IIS 7
- My Website => Pointing at the "Website" folder
- Webservices Application => Pointing at the "Webservices" folder in the Data Core
This resulted in the following url "http://website/webservices/myWebservice.asmx", which gave me the "Could not create type" error.
Now, after playing around a bit I tried hosting my webservice application starting with the data core as root, instead of the webservice folder.
Visually:
- IIS 7
- My Website => Pointing at the "Website" folder
- Webservices Application => Pointing at the "Data Core" folder.
Obviously using the same url as before would give me a "File not found" error. However, using the following url "http://website/webservices/webservices/myWebservice.asmx",I finally got my working webservices page!
A small url breakdown:
- http ://website/ => My website from the "Website" folder
- webservices/ => Equivalent to the "Data Core" folder
- webservices/ => The "webservices" folder in the "Data Core" folder
- myWebservice.asmx => The webservice file in the "webservices" folder, in the "Data Core" folder
I assume that because I was hosting my webservices directly from the "webservices" folder in the Data Core, that the server could not find the compiled DLL of the webservices (which resides in the "bin" folder), since I was hosting at a deeper level.
After changing the configuration and hosting the webservices from the "Data Core" folder, the IIS server could "see" the bin folder and host the webservices succesfully. When using the correct url that is ^_^
I hope this is clear and helps you with you problems!