NUnit System.IO.FileNotFoundException Error
Posted: 20/08/2012 Filed under: Testing | Tags: Error, NUnit Leave a comment »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
Posted: 13/08/2012 Filed under: Visual Studio | Tags: Error Leave a comment »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.
.getJSON Error
Posted: 08/06/2012 Filed under: JavaScript | Tags: Ajax, Error, jQuery Leave a comment »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.
Posted: 22/02/2012 Filed under: Programming | Tags: C#, Error Leave a comment »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
Posted: 21/10/2011 Filed under: Uncategorized | Tags: Error Leave a comment »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.
Posted: 21/07/2011 Filed under: Uncategorized | Tags: DataBinding, Error, GridView Leave a comment »I got the error (as below) attempting to bind list items (SPListItemCollection) into a GridView control.
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.
Posted: 11/10/2010 Filed under: Uncategorized | Tags: Configuration, Error Leave a comment »If you ever get this 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.