[Using Visual Studio 2005] Using a Class defined outside any project
My question is quite simple :
I've got two C# projects in a solution.
with that i create a C# class outside any project, it's only a log class
I want to use my logger into my two projects, how can i do that ?
I try tu put my class in "Solution Items" but i can't use my logger
In C++ i could include my class passing it's path but how i do that in a C# project ?
It will create a new dll no ?
And i don't want to create a new dll, i just want to have a class used in two project defined in one file (only one) !
It is possible in C++ C Java php and ada, don't tell me it's impossible with C# oO
Yes i can but if i create 235666456456 projects what i do ?
In fact we found something, add the file as a link in all projects, but now we have warnings
Warning 1 'CSLogger.CSLogger' is defined in multiple places; using definition from 'd:\Mes documents\Visual Studio 2005\projects\CSWinTelecopie\CSLogger.cs' d:\Mes documents\Visual Studio 2005\projects\CSWinTelecopie\CSLogger.cs 15 26 Seems to have multiple definition of our logger :o(, do you know what to do to remove these warnings ?
It would be great if you can send a sample code of the scenario along with the steps to reproduce the problem.
You could also 'right-click' on the warning message and choose 'Show Error Help' in the context menu for more information on the warning and see if the information there helps (For this to work you would need to have MSDN installed on the machine and it needs to be integrated with Visual Studio).
Additionally, try posting this question in the Visual Studio General or the Visual C# General group...
Thanks
Well i'll try to be as cleaar as possible.
(MSDN is not installed on my desktop sorry)
1 - I create a class, a simple log class but it can be what you want (i try an empty class)
2 - I start a project in visual stuidio 2005 B2 an insert as an solution item my class file
3 - In my project i add "as link" the MyClass.cs file
--+MySolution
|
+Solution items+
| |
| MyClass.cs
+MyProject1+
| |
| LinkToMyclass.cs
|
+MyProject2+
|
LinkToMyclass.cs
As a result i can build and deploy my solution and all works perfectly, but i've these famous warnings :
Warning 1 'CSLogger.CSLogger' is defined in multiple places; using definition from 'd:\Mes documents\Visual Studio 2005\projects\CSWinTelecopie\CSLogger.cs' d:\Mes documents\Visual Studio 2005\projects\CSWinTelecopie\CSLogger.cs 12 24
It seem that somethign in visual studio do not make the difference between a link and a real file, but all the deploy process is good and lead to a "normal" set of assembly
My question is still why these warnings...
Hi,
The recommended way of doing this is to use a classlibrary and hence there is no way to *link* the file. Now you could just copy across the same source file to both projects but you will need to update the source code in both places in case of any updates.
As for you famous warning, I think you are getting that since you are referencing MyProject1 in MyProject2 or the otherway round. Now when you do that, both of these projects will have a class with identical definition which in other words means you have a duplicate definition or a class defined in multiple places - thats the reason for ur warning. If you change the namespace for CSLogger to something different, the warning should go away.
Regards,
Vikram