Quote:
quote:Originally posted by cfouquet
VB seems to behave differently from c#..
...
The IDE seems to 'know' that the Global class fullname is Production.Global even though there is no "Namespace Production"
statement in the vb file
|
No, they behave the same. The difference is in project configuration and how the resulting code is compiled by Visual Studio.
[u]VB</u>
You can set the root namespace of your project in the project configuration. **This is not the same as setting the project name. If you change the project name, it will not change the root namespace.** Any class in your project will fall under the configured root namespace. In the situation in question, the project *should* be configured with the root namespace "Production". Then the global class that is defined in the global.asax.
vb file looks like this:
Public Class Global
...
End Class
The resulting assembly should be "Production.dll" and the global class inside it can be referenced by "Production.Global" which is what you see in the "@ Application" directive of the global.asax.
[u]C#</u>
There is no root namespace in a C# project. There is however a default namespace. When you add a new C# item to the project, it will get the "namespace <default namespace>" line of code automatically. This then defines the namespace the class is in.
There is also a configuration setting to set the assembly name of the DLL. This, as well as the default namespace, is by default the same as the name of the project. However, like in
VB, if you change the project name you'll get discrepencies. You should strive to keep all of these names, plus the namespace declaration of the classes, the same to avoid these kinds of headaches. The capability exists to create classes in different namespaces, but it breaks consistancy and could lead to confusion later on.
Once the C# assembly is compiled, the class will look exactly the same as its
VB counterpart and the global.asax will reference it the same way.
Peter
-------------------------
Work smarter, not harder