Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GuiD Conflict

Posted on 2013-11-12
2
Medium Priority
?
416 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
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

Technology Partners: 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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

885 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