I created my custom DLL "MongoDbExtensions". Now in a new project I add a reference to the "MongoDbExtensions" and then try to invoke a method inside the MongoDbExtensions called ToDocument. I use resharper to add the namespace at the top of the file but when I compile I still get the following error:
Error 1 The type or namespace name 'MongoDbExtensions' could not be found (are you missing a using directive or an assembly reference?) C:\Projects\HelpForum\DemoConsole\Program.cs 6 7 DemoConsole
What is going wrong? My DLL can be downloaded from here:
http://github.com/azamsharp/开发者_开发百科MongoDbExtensions/downloads
UPDATE 1:
Here is the MongoExtensions class:
namespace MongoDbExtensions
{
public static class MongoExtensions
{
public static List<T> ToList<T>(this IEnumerable<Document> documents)
{
var list = new List<T>();
var enumerator = documents.GetEnumerator();
while (enumerator.MoveNext())
{
list.Add(enumerator.Current.ToClass<T>());
}
return list;
}
}
}
ToDocument is an extension method that works on Object.
I repro. This DLL was built targeting .NET 4.0. You cannot use it in a project that targets anything else but the full 4.0 .NET framework. Either targeting a lower version or the client profile will produce this error.
Since your class is called MongoExtensions, you need to change MongoDbExtensions in your test project source code to MongoExtensions.
加载中,请稍侯......
精彩评论