Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GuiD Conflict

Posted on 2013-11-12
2
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39646117
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 2000 total points
ID: 39646540
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

718 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