yasser777 / nettiers

Automatically exported from code.google.com/p/nettiers
0 stars 0 forks source link

Having multiple nettiers projects in one solution causes loading and validation issues #378

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. have 2 nettiers projects for 2 separate databases with significantly 
different structure
2. generate code for these projects and include in solution
3. in another project, reference structures from the individual nettiers 
projects
4. attempt to compile main project. many errors will occur as compiler is 
looking for references in the wrong project. 

What is the expected output? What do you see instead?
VS should have been able to correctly locate the referenced classes. as 
multiple projects with the same GUID are included, VS does not correctly locate 
the right reference for this object. 

What version of .netTiers and CodeSmith are you using?
Codesmith 5.2.2 Rev 11561
nettiers 2.3.0.843

Please provide any additional information below.
I have found that this problem is being caused by explicitly hardcoding GUIDs 
on the different projects. I understand the reason this solution was chosen as 
doing so made it easier to keep the solution working upon multiple generation 
cycles. However, this causes issues when using multiple nettiers projects as 
these guids will exist in multiple places. What seems to be needed lies between 
a hard-coded GUID and a random generated GUID.

SOLUTION:
I've included this solution in our project and it works to our needs.
Using it this way means that it's the namespace that describes the uniqueness 
of the projects and regeneration of projects will act similar to hard-coded 
GUIDs as long as the namespace has not been changed (otherwise users will have 
to drop and add nettiers projects to let VS rekey them) Multiple projects 
should have different namespaces and thus, will produce different project 
GUIDS, however these will remain once the namespace has been chosen.

----CommonSqlCode.cs---
public static string GenerateDeterministicGuid(string input)
        {
            MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
            byte[] inputBytes = Encoding.Default.GetBytes(input);
            byte[] hashBytes = provider.ComputeHash(inputBytes);

            Guid hashGuid = new Guid(hashBytes);

            return hashGuid.ToString();
        }
----End CommonSqlCode.cs----

change the guid generation to get the guid from the namespace
----NetTiers.cst---- 
// Line 2757
tring bllGuid = GenerateDeterministicGuid(BLLNameSpace); 
//Guid.NewGuid().ToString();
string dalGuid = GenerateDeterministicGuid(DALNameSpace); 
//Guid.NewGuid().ToString();
string DALSqlGuid = GenerateDeterministicGuid(DALSqlNameSpace); 
//Guid.NewGuid().ToString();
string DALWSGuid = GenerateDeterministicGuid(DALWSNameSpace); 
//Guid.NewGuid().ToString();
string DALGenericGuid = GenerateDeterministicGuid(DALGenericNameSpace); 
//Guid.NewGuid().ToString();
string wsGuid  = GenerateDeterministicGuid(WSNameSpace); 
//Guid.NewGuid().ToString();
string utGuid  = GenerateDeterministicGuid(UTNameSpace); 
//Guid.NewGuid().ToString();
string webLibGuid = GenerateDeterministicGuid(WebLibNameSpace); 
//Guid.NewGuid().ToString();
string websiteGuid = GenerateDeterministicGuid(WebsiteNameSpace);
string componentGuid = GenerateDeterministicGuid(ComponentsNameSpace); 
string winLibGuid = GenerateDeterministicGuid(WebLibNameSpace); 
//Guid.NewGuid().ToString();
string websecurityGuid = GenerateDeterministicGuid(WebSecurityLibNameSpace); // 
ADDED BY CHARLIE
---- End NetTiers.cst----

Original issue reported on code.google.com by beta...@gmail.com on 3 Mar 2011 at 5:40

GoogleCodeExporter commented 9 years ago
Hello,

I believe this change has been committed in the latest nightly build. Can you 
please verify that this is the case.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 4 Mar 2011 at 8:08