1

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.

1
  • right click on added reference MongoDbExtensions and select object browser. Now in the browser check the structure to call ToDocument(). From there you get the namespace and calss under which it is called. That will help you in resolving Commented Jul 18, 2010 at 19:29

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to use it on a .NET 4.0 project!
Thanks Hans! you are right! I switched to .NET 4.0 and now it started working. Thanks for the tip!
0

Since your class is called MongoExtensions, you need to change MongoDbExtensions in your test project source code to MongoExtensions.

2 Comments

Yeah, precisely make calls to MongoDbExtensions.MongoExtensions, e.g.: MongoDbExtensions.MongoExtensions.BetterInsert(myColl, myDoc) or insert corresponding using statements.
What do you mean by test project source code? I am using Resharper to add my references and still it is giving the same error!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.