I have built a windows phone 7 library and I created a test project at the same time. When I run the tests, I get the following error:
System.IO.FileNotFoundException: Could not load file or assembly“System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e”
But the reference was already in the project. This is the code in the class:
public class SinaApiService
{
public string userName;
public string passWord;
private string secertKey;
public string SecertKey
{
get { return secertKey; }
set { secertKey = value; }
}
private bool needInitWebClient = true;
public static System.Net.WebClient wc;
public void InitSinaApiService(string userName, string passWord, string secretKey)
{
if (needInitWebClient)
{
this.userName = userName;
this.passWord = passWord;
this.SecertKey = secertKey;
needInitWebClient = false;
wc = new WebClient();
wc.Credentials = new NetworkCredential(userName, passWord);
wc.Headers["Authorization"] = "Basic" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(userName + ":" + passWord));
}
else
{ }
}
}
When i do the unit test like this:
[TestMethod]
public void TestMethod1()
{
WPSina.SinaApiService wc = new WPSina.SinaApiService();
wc.InitSinaApiService("hello@gmail.com", "XXXXX", "123456"); ;
wc.public_timeline();
object obj = WPSina.SinaApiService.public_timeline_context;
Assert.AreNotEqual(null,obj.ToString());
}
Can anybody help to solve it?
Thanks!!
Does the file exists? It should be here: c:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\Silverlight\\v4.0\\Profile\\WindowsPhone\\System.Net.dll
If it is not present (on x86 OS look into your c:\\Program Files... folder) try uninstalling and installing the WPDT again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.