Having trouble adding Moq.dll reference to vs2010

1,265 views
Skip to first unread message

qin

unread,
Feb 1, 2011, 1:15:52 PM2/1/11
to Moq Discussions
So I downloaded the latest version of Moq (Moq.4.0.10827.zip). I am
using vs2010 with .NET framework 4.0. The following is the warning
and error I get when I try to compile my code. Note that I have added
Moq.dll from NET40 folder to the reference.


Warning 1 The referenced assembly "Moq" could not be resolved because
it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently
targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please
remove references to assemblies not in the targeted framework or
consider retargeting your project. MoqTest

Error 2 The type or namespace name 'Moq' could not be found (are you
missing a using directive or an assembly reference?)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Moq;

namespace MoqTest
{
class Program
{
static void Main(string[] args)
{
}
}
}

Any ideas?

dewald galjaard

unread,
Feb 2, 2011, 8:14:07 AM2/2/11
to moq...@googlegroups.com

The second error is related to the first.

I'm not sure why you're getting that error but it might depend on what kind of project you're building. I usually create a class library and havn't seen that before. Just add the reference and see what happens?

 

 


Mariano Omar Rodriguez

unread,
Feb 2, 2011, 8:16:36 AM2/2/11
to moq...@googlegroups.com
The solution is simple, change the Target Framework of your Test Project from “.NET Framework 4.0 Client Profile” to “.NET Framework 4.0”.

David Allen

unread,
Feb 2, 2011, 8:17:11 AM2/2/11
to moq...@googlegroups.com
Your project properties target the framework .Net Framework 4 Client Profile. Change to .net fw 4, which is the Fulll profile, and all will be good.




--
David Kreth Allen
http://codecontracts.info

dewald galjaard

unread,
Feb 2, 2011, 8:18:13 AM2/2/11
to moq...@googlegroups.com
Wonder why it would be that by default.

qin

unread,
Feb 2, 2011, 10:40:29 AM2/2/11
to Moq Discussions
Thank you so much, that solved my problem.

On Feb 2, 8:16 am, "Mariano Omar Rodriguez" <marian...@gmail.com>
wrote:
> The solution is simple, change the Target Framework of your Test Project from “.NET Framework 4.0 Client Profile” to “.NET Framework 4.0”.
>
> From: dewald galjaard
> Sent: Wednesday, February 02, 2011 10:14 AM
> To: moq...@googlegroups.com
> Subject: Re: [Moq] Having trouble adding Moq.dll reference to vs2010
>
> The second error is related to the first.
>
> I'm not sure why you're getting that error but it might depend on what kind of project you're building. I usually create a class library and havn't seen that before. Just add the reference and see what happens?
>
Reply all
Reply to author
Forward
0 new messages