Full Error
An attempt was made to remove a relationship between a [Table1] and a [Table2]. However, one of the relationship's foreign keys ([Table1].[Foreign Key]) cannot be set to null.
This error usually occurs when trying to called SubmitChanges() on the data context.
For example, I have received this error when trying to commit an object and I have not property build up its properties (one of which may be another table) and when trying to commit this parent object, its related table will be null; this throws an error.
So what you could do is...
1. Ensure the property is present (that is, if you want to commit it in one transaction).
2. Tell the framework to delete child items on submitting... Open the DBML file in Xml Editor (Right Click > Open With...) and find the association and tag " DeleteOnNull="true" " to the end.
- Alternately, you can specify this in the code... DataContextInstance.TableName.DeleteAllOnSubmit(items);
3. Remove the table reference as a property all together. Open the DBML file, click on the association and view the properties. Set 'Child Property' to 'False'.
Hope this helps!
Technical blog discussing various programming languages, frameworks and paradigms. Code snippets and projects are also provided.
Wednesday, 30 June 2010
Wednesday, 16 June 2010
iPhone SDK in Windows
Here's a good guide on getting the iPhone SDK working from a windows isntallation.
http://iphone-sdk-in-windows.co.uk/
Labels:
iPhone
Friday, 11 June 2010
CruiseControl.NET: 10 Useful Plugins [Written in C#.NET]
For the past two years I have developed various Continuous Integration systems and along the way, like most things, you collect a lot of information. Recently, I have managed to compile most of this into this solution and kept it up to date.
For the build process of our Continuous Integration, we can give CruiseControl.NET as much power as we desire. Most developers prefer to keep logic in Nant/MSBuild scripts, while some find themselves using CCNET plugins to manage a lot of the work.
In this solution attached, I have included all of the plugins I have developed and have used within some of my processes (I say some because the other use build scripts to perform similar actions). I have updated the solution to work with CCNET v1.5 [1.5.6804.1 to be specific].
If you don't have this particular version, you can either upgrade to it, or easier, copy the required files into the 'References' folder and recompile the plugins. The files required are:
- ThoughtWorks.CruiseControl.Core.dll
- NetReflector.dll
- Wix.dll
These can all be found in the 'server' directory of your CCNET setup. Remember, with plugins, the file names are specific (NOTE: all must start with ccnet and end within plugin.dll). This has already been done.
Included in the ZIP file are the following plugins:
- Banty.AssemblyInfoUpdater - Updates assemblyinfo files with a CCNET build version number.
- Banty.CustomVersioner - Enables a custom versioner (labeller) with wildcard support.
- Banty.MSILister - Lists and produced a packing file to display the contents of an MSI file as XML.
- Banty.TestHarness - Used to test the plugins locally
- Banty.VersionMSIFile - Injects a CCNET version into an MSI file
- Banty.VersionWixFile - Injects a CCNET version into a Wix Setup project
- Banty.VSSCommentCollector - Collects VSS comments for the build.
- CCNet.Sequential.PlugIn+Unittests (External project updated to latest version)
- MsBuildToCCNet (External project by rodymeister)
Working with ASP.NET, JQUERY and JSON [EXAMPLES]
I have put together some examples of working with ASP.NET, JQUERY and JSON. The examples use three techniques:
- Page Methods
- Web Services
- WCF Services
and neither of them use UpdatePanels or ScriptManagers to display dynamic content, worth a look!
The file is for .NET Framework 3.5 and written in C#.
JQuery: Calling ASP.NET Page Methods
Here is a great page explaining how to call page methods directly using JQuery.
Friday, 4 June 2010
Error connecting to undo manager of source file "designer file here"
This error happens a lot with visual studio, up to and including VS2008. The reason being that VS keep track of the form designers in debug mode by creating 'designer' files for each ASP.NET or each Windows Form etc...
This usually occurs, for whatever reason, when the designer file cannot be updated, usually being its corrupted. To resolve this error, simply do the following...
ASP.NET
1) Right-click the designer file and select delete
2) Right-click the aspx file and select Convert to Web Application
2) Right-click the aspx file and select Convert to Web Application
Other Project Types
Exclude the file from the Project, recompile, then re-include, the recompiles.
Wednesday, 2 June 2010
.NET: LoaderLock was detected
Error Message
Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
The problem can be solved by switching off the MDA:
Debug -> Exceptions -> Managed Debug Assistants
and unchecking the LoaderLock item.
This simply tells visual studio that you do not wish to be alerted by this exception everytime you debug the application.
Restore SQL Server Database from .BAK backup file
You would think that restoring a backup would be fairly straight forward, but usual, this isn't always the case. We need to create an MDF (database) and LDF (log file) from the .BAK file, and plug this into SQL Server. urgh.
First things first... Run the below command to find out the logical names of the MDF and LDF files. I recommand running this under the master database or you will receive a 'database in use' error message.
Now we have these names, we can restore to them using the following command. We can specify a UNC path to the BAK file incase we want to update over a network, but the MDF and LDF file paths cannot be UNC.
The database name will be the logical name of the MDF file... In my case, I could not get this to work until I had created a database with the same name before hand.
Ensure the directories above exist otherwise it will not work. I chose to place them with my other SQL Server table definitions.
First things first... Run the below command to find out the logical names of the MDF and LDF files. I recommand running this under the master database or you will receive a 'database in use' error message.
RESTORE FILELISTONLY
FROM DISK = 'C:\dbbackup.bak'
Now we have these names, we can restore to them using the following command. We can specify a UNC path to the BAK file incase we want to update over a network, but the MDF and LDF file paths cannot be UNC.
RESTORE DATABASE [TESTDB]
FROM DISK = 'C:\dbbackup.bak'
WITH REPLACE,
MOVE 'TESTDB' TO 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TESTDB.MDF',
MOVE 'TESTDB_log' TO 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TESTDB_log.LDF'
The database name will be the logical name of the MDF file... In my case, I could not get this to work until I had created a database with the same name before hand.
Ensure the directories above exist otherwise it will not work. I chose to place them with my other SQL Server table definitions.
Subscribe to:
Posts (Atom)