Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace & Class Conflict

I'm facing a problem with a conflict between the DateTime class and a namespace for some unknown reason was also called DateTime.

Assembly CompanyDateTime has namespace Company.DateTime

My Application is in the namespace: Company

the problem is that everytime I need to use DateTime class, I have to explicitely say System.DateTime is their any way of getting around this?

Is is possible to say SomeRandomStuff = Company.DateTime and have DateTime always be System.DateTime

Note:

  1. I need to reference this Assembly in my application eventhough I do not use it because some Assembly that I need actually uses this class.
  2. I can use an entry on the app.config file to identify a dependent assembly but I cannot do that since company policy is against it and all referenced assembly needs to be in the output folder.
  3. Deployment goes through a build server

Possible Resolution? Is is possible for CompanyDateTime to get automatically deployed to the output folder without adding it in the reference?

like image 749
Viv Avatar asked Sep 17 '10 13:09

Viv


1 Answers

Question : the problem is that everytime I need to use DateTime class, I have to explicitely say System.DateTime is their any way of getting around this

Answer : Already answered above - use an Alias eg

using CompanyDateTime = Company.DateTime;

using StandardDateTime = System.DateTime;

Question : Is is possible for CompanyDateTime to get automatically deployed to the output folder without adding it in the reference?

Answer : Put this dll in the application root folder and create a postbuild event that copies this to the output folder. You can use the regular DOS COPY command here.

Refer link for postbuild event details

like image 148
Jagmag Avatar answered Sep 26 '22 17:09

Jagmag