Solved

GuiD Conflict

Posted on 2013-11-12
2
387 Views
Last Modified: 2013-11-14
I have a questioon on Guid Whether the same Guid can be used from 1 application to another or will it cause any Build Issues.

Since there are 2 applications(app1 and app2) that almost behave in similar functionality. I have used this code below to create another application but this Guid remains constant which I am afraid if I run app2 it will create a promblem in app1. Is that the case...

OR is it the public class Name that I need to change to avoid any name conflict.. Need advise

namespace MobizSalesApplication
{
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("69D98FE7-90D6-4597-9476-8EABC68739E5")]
    [ComVisible(true)]
    public interface INAVClient
    {
        string DealerRetrieve(string User_Cred, string alldet, string Amt);
        string WarehouseRetrieve(string User_Cred, string alldet, string Amt);
    }

    [ComVisible(true)]
    [Guid("160601f8-3b38-4735-b4f8-8fc6bf48a601")]
    [ClassInterface(ClassInterfaceType.None)]
    public class NAVClient : INAVClient
    {
        //List<string> det;
        //List<string> custflddet;
        //string bday;
        //string anvday;
        List<string> line_items = new List<string>();
        string XMLResp;
        public NetworkCredential crytography(string UserName, string Password)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bytedata = System.Text.Encoding.ASCII.GetBytes(Password);
            byte[] hash = md5.ComputeHash(bytedata);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2"));
            }
            string pwdmd5 = sb.ToString().ToLower();

            StreamWriter UserStreamWriter = new StreamWriter(@"C:\InTouchAutomationLogFiles\usrDetails.txt", false);
            UserStreamWriter.WriteLine(pwdmd5 + "--" + UserName + "--" + Password);
            UserStreamWriter.Close();

            return new NetworkCredential(UserName, pwdmd5);
        }


        public string WarehouseRetrieve(string User_Cred, string alldet, string Amt)
        {
            try
            {
                string WarehouseUrl = @"http://wildcraft.bizom.in/warehouses/add?calltype=api&username=wildcraftnav&password=wildcraft";
                string[] det = alldet.Split('^');
                string WarehouseData_XML = String.Empty;
                string[] user = User_Cred.Split(',');
                using (StringWriter SW = new StringWriter())
                {
                    using (XmlTextWriter XTW = new XmlTextWriter(SW))
                    {
                        XTW.WriteStartDocument();
                        XTW.WriteStartElement("Warehouses");
                        XTW.WriteStartElement("Warehouse");
        
                        XTW.WriteElementString("erp_id", det[1]);
                        XTW.WriteElementString("zone_id", det[2]);
                        XTW.WriteElementString("name", det[3]);
                        XTW.WriteElementString("address", det[4]);
                        XTW.WriteElementString("state", det[5]);
                        XTW.WriteElementString("city", det[7]);
                        XTW.WriteElementString("state_id", det[6]);
                        XTW.WriteElementString("taxno", det[8]);
                        XTW.WriteElementString("jurisdiction", det[9]);
                        XTW.WriteElementString("tnc", det[10]);
                        XTW.WriteEndElement();//end of Warehouse
                        XTW.WriteEndElement();//end of Warehouses
                        XTW.WriteEndDocument();

                    }
                    WarehouseData_XML = SW.ToString().Replace("utf-16", "utf-8");
                }

                StreamWriter Vouch_writer = new StreamWriter(@"C:\MobizSalesAppLogFiles\" + user[0].Replace(".", "_") + "_WarehouseAdd.txt", true);
                Vouch_writer.WriteLine("----New----");
                Vouch_writer.WriteLine(User_Cred);
                Vouch_writer.WriteLine("-------------");
                Vouch_writer.WriteLine(WarehouseData_XML);
                Vouch_writer.Close();


                XmlDocument resp_XML = new XmlDocument();
                resp_XML.LoadXml(this.ReturnPostUrl(WarehouseUrl, WarehouseData_XML, User_Cred));



                StreamWriter WarehouseIDResponse = new StreamWriter(@"C:\MobizSalesAppLogFiles\" + user[0].Replace(".", "_") + "_ResponseOfPost.txt", true);
                WarehouseIDResponse.WriteLine("-----New----");
                WarehouseIDResponse.WriteLine(User_Cred);
                WarehouseIDResponse.WriteLine(DateTime.Now.ToString());
                WarehouseIDResponse.WriteLine("------------");
                WarehouseIDResponse.WriteLine(resp_XML.InnerXml);
                WarehouseIDResponse.Close();

                if (resp_XML.GetElementsByTagName("is_absolute")[0].InnerText == "true")
                    return resp_XML.GetElementsByTagName("coupon_value")[0].InnerText;
                else
                    return resp_XML.GetElementsByTagName("coupon_value")[0].InnerText + "%";



            }
            catch (Exception ex)
            {
                StreamWriter AddDealer_Exception = new StreamWriter(@"C:\MobizSalesAppLogFiles\Warehouse_Error.txt", true);
                AddDealer_Exception.WriteLine("----New1----");
                AddDealer_Exception.WriteLine(User_Cred);
                AddDealer_Exception.WriteLine("-------------");
                AddDealer_Exception.WriteLine(ex.ToString());
                AddDealer_Exception.WriteLine(ex.Message + "message");
                AddDealer_Exception.WriteLine(ex.StackTrace + "stacktrace");
                AddDealer_Exception.WriteLine(ex.Source + "source");
                AddDealer_Exception.Close();
                return "";
            }
        }

Open in new window

0
Comment
Question by:Moizsaif123
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
If you are applying a GUID to classes that are COM visible, then the GUIDs need to be unique between the classes.  If two assemblies use the same class, then they can have the same GUID.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
GUID is a Global Unique Identifier. It the same thing as a social security number. It's a way to uniquely identify something in order to differentiate 2 things that have the same name. A given GUID should never be reused for something else. You defeat the whole purpose of GUIDs if you do so.

Part of systems that use GUID use it instead of the class name to identify it. If you use it for 2 classes, the system might sometimes use class1 while you are expecting class2, and vice-versa.

With COM, you might have problems registering your 2 classes with the same GUID. I haven't worked with the registry for years, but it used to be that you could not register 2 classes having the same GUID. The second one you registered just override the registration of the first one.

And unless you have a good reason to do so, you usually do not provide the GUID through the GuidAttribute. Look at the documentation: "Only use an explicit GUID when a type must have a specific GUID. If the attribute is omitted, a GUID is assigned automatically."
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now