Share via


Error: The name assert does not exist in the current content.

Question

Sunday, January 1, 2012 9:00 PM

Hi,

I am using the line  "Assert.IsNotNull(object);" in my code. I keep getting the error "the name assert does not exist in the current content". 

Can someone please tell me what I'm missing?

Thanks.

All replies (3)

Monday, January 2, 2012 12:47 AM ✅Answered | 1 vote

Add a reference to your project: Microsoft.VisualStudio.QualityTools.UnitTestFramework

And then add the following using to your code file:

using Microsoft.VisualStudio.TestTools.UnitTesting;

It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.


Monday, January 2, 2012 1:11 AM ✅Answered | 1 vote

If you are doing unit testing, then TSoftware recommended a good solution.  If this code is in "production code", then more likely you would want to use System.Debug.Assert(object != null); or System.Trace.Assert(object != null);.

--
Mike


Sunday, January 1, 2012 10:20 PM | 1 vote

Hello k560,

Hi,

I am using the line  "Assert.IsNotNull(object);" in my code. I keep getting the error "the name assert does not exist in the current content". 

Can someone please tell me what I'm missing?

Thanks.

This error usually occurs when the object is not part of the class in which the state, or since c # case sensitive and language, which is case-sensitive check if you typed the name correctly.

Regards.