Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) Exception in LoadFromStream when strong named key file changed (Read 10530 times)
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Exception in LoadFromStream when strong named key file changed
Reply #15 - Feb 13th, 2017 at 7:09am
Print Post  
Based on answers from http://stackoverflow.com/questions/5794686/serializationbinder-with-listt, this fixed the Dictionary<string, MyTag> exception for me -

Code
Select All
public override Type BindToType(string assemblyName, string typeName)
{
	if (assemblyName.StartsWith(Assembly.GetExecutingAssembly().GetName().Name))
		return Assembly.GetExecutingAssembly().GetType(typeName);
	if (typeName.Contains("[["))
		return Type.GetType(StripAsmStrongName(typeName));
	return null;
}

string StripAsmStrongName(string genericTypeName)
{
	while (true)
	{
		int index1 = genericTypeName.IndexOf(", Version");
		if (index1 == -1)
			return genericTypeName;
		int index2 = index1 + genericTypeName.Substring(index1).IndexOf("]");
		genericTypeName = genericTypeName.Remove(index1, index2 - index1);
	}
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 125
Location: England
Joined: Oct 23rd, 2006
Re: Exception in LoadFromStream when strong named key file changed
Reply #16 - Feb 15th, 2017 at 10:16pm
Print Post  
Sorry for delay, I did not see the second page of postings (the page numbers are very small or maybe I need new glasses!)

Your solution works perfectly Smiley Many thanks - with the right search terms StackOverflow often comes up with the answer. I don't think I searched for the right thing.

Thanks again,
DavidL
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint