Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Bob Swart (aka Drs.Bob) Dr.Bob's Delphi Clinics Dr.Bob's Delphi Courseware Manuals
View Bob Swart's profile on LinkedIn Drs.Bob's Delphi Notes
These are the voyages using Delphi Enterprise (and Architect). Its mission: to explore strange, new worlds. To design and build new applications. To boldly go...
Title:

CS1595: Global.TGlobal defined in multiple places

Author: Bob Swart
Posted: 9/2/2005 12:22:55 PM (GMT+1)
Content:

Using Delphi to develop ASP.NET projects can be quite fun, especially when deployment reuslts in a working application.
However, when you try to deploy a second ASP.NET project (in the same virtual directory), some people may encounter a compiler error when trying to run either application in a browser window:

  Compiler Error Message: CS1595: 'Global.TGlobal' is defined in multiple places; 
using definition from 'c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET\...
Note that this is not a Delphi compiler error, but a C# compiler error, produced by the ASP.NET worker process trying to make sense of your Delphi code behind assemblies and the classes found inside.

The error message can be seen sometimes if you have more than one Delphi for .NET ASP.NET code behind assembly deployed in the same virtual directory on your web server, using the same Global.TGlobal classname. By default, each Delphi ASP.NET project will get a unit called Global.pas belonging to a Global.asax, defining a TGlobal class (hence the full typename Global.TGlobal).

Each compiled code behind assembly will use its own TGlobal class - even if you didn't implement it. If you also deploy the Global.asax file, then the ASP.NET worker will look for the TGlobal class, and will find multiple code behind assemblies that all implement the TGlobal class (potentially all in the same way, but that doesn't matter).
So the problem occurs when multiple code behind assemblies all contain the same TGlobal class, since these classes are all called TGlobal and were all implemented in unit Global.pas.

As a fix, you need to rename the TGlobal type in your ASP.NET project to make sure each ASP.NET project uses a unique TGlobal type name. I often rename TGlobal to TGlobalXXX type where the XXX stands for something specific to the project. The error will also go away if you remove (don't deploy) the Global.asax file, but that may not be what you want, since that means you don't be using your TGlobalXXX classes as Application class.

Finally, for similar reasons, you may encounter error messages about a TWebForm1 being defined in multiple places, if you don't rename your new web forms ;-)

Back  


No Comments, yet.


New Comment (max. 2048 characters, no HTML):

Name:
Comment:



This webpage © 2005-2014 by Bob Swart (aka Dr.Bob - www.drbob42.com). All Rights Reserved.