2
votes

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("[email protected]", "XXXXX", "123456"); ;
    wc.public_timeline();
    object obj = WPSina.SinaApiService.public_timeline_context;
    Assert.AreNotEqual(null,obj.ToString());
}

Can anybody help to solve it?

Thanks!!

1
i am sorry,my English is poor,so it is a little for me to ask question with the correct meaning~I - magicshui
I don't know much about phone development, so this is just a guess but don't you build phone apps against the Compact version of the framework? My guess is your building against the wrong version of .Net. - asawyer
ok,thanks,i will try other .NET frame - magicshui
Fixed up the question a bit. I am having the same issue. Did trying other versions fix the issue? - Craig

1 Answers

0
votes

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.