Solved

GuiD Conflict

Posted on 2013-11-12
2
410 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 500 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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