NUnit System.IO.FileNotFoundException Error

I keep getting this error when I try to open my assembly System.IO.FileNotFoundException Could not load file or assembly or one of its dependencies. The system cannot find the file specified.

There was nothing wrong with the assembly nor the location of it’s files. I can actually build and run the solution with no errors at all.

I eventually discovered that that the .NET runtime set on the NUnit config file by default is for .NET version 2.0 and my solution was built on .NET 4.0.

In order to get this going, navigate to your NUnit bin directory location, and open up the nunit.exe.config file with a text editor. Look for element as shown below:

   1: <startup useLegacyV2RuntimeActivationPolicy="true">

   2:   <!-- Comment out the next line to force use of .NET 4.0 -->

   3:   <supportedRuntime version="v2.0.50727" />

   4:   <supportedRuntime version="v4.0.30319" />

   5: </startup>

As the comment line indicates, just comment out the version of .NET runtime that you’re not going to be using. And now we can begin Unit Testing :)


Error Entering break mode failed

I got the following error after copying over my solution from my development server into my laptop and tried debugging the solution. The full error is as below:

Entering break mode failed for the following reason <filename> does not belong to the project being debugged.

I tried re-building my solution and closing and opening up Visual Studio with no luck :(

Eventually, I tried to clean my solution, but because I only had Visual Studio Express this option was not available to me.

The resolution? I manually deleted the bin and obj folders from my solution directory then opened the solution and rebuild it again. This worked like a charm, hope it helps you.

err


.getJSON Error

If you get a ‘context’ is null or not an object error, have a look at the JavaScript files that you are referencing on the page. It is known that the problem lies with the vsdoc file. Remove that reference from the page and only use your jQuery file and all will be fine again.


Error Object cannot be cast from DBNull to other types.

This happens when the database is returning an object of type DBNull. Best approach towards handling this error would be to check if the object is of type DBNull first, before attempting to use it. Sample snippet below demonstrates this, using the Convert.IsDBNull method.

   1: var reader = command.ExecuteReader() // assumes SqlCommand has been initialised

   2:  

   3: if(!Convert.IsDBNull(reader["DateInDatabase"])) // if it is not returning DBNull

   4: {

   5:     // Do Something

   6: }

Hope this helps.


Error System.InvalidOperationException

Had this exception thrown while enumerating SPListCollection within a SPWeb. Full exception error is as below.

Unhandled Exception: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at Microsoft.SharePoint.SPBaseCollection.SPEnumerator.System.Collections.IEnumerator.MoveNext() Collection was modified IEnumeration error

Resolution

I changed my code from a foreach to a for and it worked hassle free.


Data Binding Error Object reference not set to an instance of an object.

I got the error (as below) attempting to bind list items (SPListItemCollection) into a GridView control.

gridView_BindNullValue

Obviously this meant that there were null objects coming through. One way to avoid this is error, is to check if the fields within the list are not null and then also handle the above mention error.

// get item object from item collection
SPListItem oItem = oItemGroup[i];

// get fields from item
object colSampleName = oItem["Sample Name"];
object colSampleDate = oItem["Sample Date"];

if((colSampleName != null) && (colSampleDate != null))
{
    // databinding operations
}

// handle exception

Hope this helps.


The Project Application Service doesn’t exist or is stopped.

If you ever get this error

pro_Error

From Central Administration, under Operation click on Services then select the Project Application server role option to see the Project Application Service. Start the service and all is good and pure in the world again.

Note, you may not see this service when other server role options are selected.

prj_Error2


Follow

Get every new post delivered to your Inbox.