Custom control defined in multiple places

lounge56

Newcomer
Joined
Feb 5, 2004
Messages
14
Hello! I have an .aspx page where I register a simple Custom Control. When I run the C# version of the project in 2002 Visual Studio.NET IDE, I get:

Compiler Error Message: CS1595: 'MyCustomControls.CustomControl1' is defined in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\aspnet21days_ch6_custommade1\d3785e63\d65d6407\assembly\dl2\616735d8\14e5d5fc_ceffc301\CustomControl.DLL'

I rewrote the project in VB.NET and it worked fine.

I think I heard there was some bug related to this with specifically C#. Anyone have any solutions to this problem? My project has to be done in C#.

By the way, in both versions of the project, I am manuallly compiling the user control into MSIL DLL using the Command Prompt to the corresponding "/bin" directory in each project.

Thank you!

-ricardo
 
The project most likely holds a reference to both the compiled assembly in the "Temporary ASP.NET Files" directory, and contains the source code to the control, which is compiled along with the rest of the project. Make sure to check for duplicate references, and delete copies of the assembly that are located outside of the application's "bin" directory.
 
RE: Custom Control Defined in Multiple Places

Thank you!

I checked my source code and there are copies of the assembly located outside the bin directory.

Two questions:

1. Where do I check if there are multiple references to the custom control? the debug log shows only one reference to my Custom Control. This reference points to the copy created in the Temporary ASP.NET files. I checked the assembly info. file in this directory and it does reference the original copy of the Custom Control I compiled:

[AssemblyInfo]
MVID=a7929ddbc3855543a7cd8993dddf0303
URL=file:///c:/inetpub/wwwroot/ASPNET21Days/Ch6/CustomMade1/bin/CustomControl.DLL
DisplayName=CustomControl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

2. When you say "The project ... contains the source code to the control, which is compiled along with the rest of the project...", do you mean that I have to create the custom control in a separate project (as opposed to when I build a working copy with VB.NET that includes the Custom Control .vb file)?

Cheers!

-ricardo 8~)
 
If you're using a 3rd party control you need to first copy it to your application's "bin" directory and then reference it in your project.

On the other hand, if you're compiling your own control to its own assembly and referencing it all within the same solution, then you should compile the control prior to working on the main project, an exclude the control project from the build. Of course you could instantiate the control from within the project and have the class included in the application's assembly.
 
That did it Derek! I excluded my Custom Control from the Project Build and it then ran fine. I guess it's one of those things that tolerant VB.NET forgives while C# does not. Thank you very much for your help!

-ricardo
 
Back
Top