I have a large web app in vb.net 4.0. Its default namespace is configured in its project properties. None of the root-level classes in our app are surrounded by namespace declarations.
When I add a .asmx file to the root folder of the website, it compiles fine, but it doesn’t work for some reason (already asked why in other topics). So to get it to work, I try to surround the class declared in the .asmx by a namespace declaration. As soon as I do this, I go from zero compiler errors to about a zillion. My app can’t find ANYTHING in the root namespace. But I haven’t changed any other files, only this .asmx file.
WHY is it behaving this way? How do I prevent it from behaving this way without refactoring the entire app? I would love to blank out the default namespace and add them explicitly around every root-level class, but I’m not sure that would fly with our release manager, and I don’t even know if it would fix the problem…
When you add a namespace in VB.net around a class you have to update any references to the namespace.
As an example. If you add a namespace of
Bararound a class named “candy”, and the Root namespace isFoo(can be found in project properties -> Application -> Root namespace) you would now need to add aImport Foo.Barto any classes that were referencing it.So, for the case of your asmx markup file, if your root namespace is
Foo, and the namespace wrapper you added to your webservice wasBaryou’ll need to update your .asmx mark up to: