Unable to find assembly 'ssdsdsd, Version=1.0.0.0, Culture=neutral, PublicKeyTok

3761
4
12-03-2011 02:14 PM
EhsanRoshani
New Contributor
Hello,

I am trying to develop a code using ArcMap Add In template in VS2010
I have a serializeable struct in c# which I would like to serialize and then deserialize
I have written the following code to serialize this struct.

        [Serializable()]
        public struct Test
        {
            public double a;
            public double b;
        }

        public void Serialize(Test obj)
        {
            Stream file = File.Open(@"c:\tt.dat", FileMode.Create);
            BinaryFormatter b = new BinaryFormatter();
            b.Serialize(file, obj);
            file.Close();
        }

This code works well but when I try to deserialize the same struct in the same project it gives me this error

"Unable to find assembly 'SerializeGIS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."} System.Exception {System.Runtime.Serialization.SerializationException}


This is the deserializing function

        public Test DeSerialize(string Name)
        {
            Test Obj = new Test();

            try
            {
                Stream  file = File.Open(Name, FileMode.Open);
                BinaryFormatter  b = new BinaryFormatter();
                Obj = (Test)b.Deserialize(file);  //This is the line which propagate the exception
                file.Close();
            }
            catch (Exception)
            {
            }
           
            return Obj;
        }

I have put both functions in a windows form application template in c# and they work perfectly but when I use them in ArcMap Add In project it raises the mentioned error

This error gives me at least 20 gray hairs today.

I would be appreciated if someone could shed some light on it.

Regards

Ehsan
0 Kudos
4 Replies
RichardWatson
Frequent Contributor
It can't find the custom assembly you reference.  One nice trick is to use the fuslogvw program (Google it) because it can display where .NET is looking for the assembly.  You need to put your assembly in a location that it can be found or simply put all the code in your addin.
0 Kudos
EhsanRoshani
New Contributor
rlwatson, Thanks for your reply.

Both serialize and deserialize functions are using the same assembly which is a class file in the project.
I even convert it to a dll and copied it all over the places (system32, bin ... esri dll folder)
but no luck. The thing which is weird is that the serialize function works well. it is just the deserialize function.

I even put both functions as a continues code in one function again serialize works but deserialize choose to not to work.

I will check fuslogvw and let you know the result.

Thanks one more time.
Ehsan
0 Kudos
EhsanRoshani
New Contributor
Still no luck, any idea would be appreciated.
E
0 Kudos
EhsanRoshani
New Contributor
Dear rlwatson,

I used fuslogvw and I found out that my code looks for the assemble in the wrong folder. and then I have copied it to the right folder and it works.

Thank you very much for introducing this tool to me.

Ehsan
0 Kudos