Results 1 to 9 of 9

Thread: c# build error

  1. #1
    Senior Member kasavien's Avatar
    Join Date
    Aug 2005
    Location
    St. Albans
    Posts
    1,829
    Thanks
    145
    Thanked
    104 times in 49 posts

    c# build error

    Hi all i'm getting a strange error when i try to build my project which is shown in the screenshot below.



    The error occurs in a user control that has been fine throughout the project but if i re-build it this error appears and the project will not build. The strange thing is that when the file is not open and i build the project it works fine and i can run the application without any problems.

    If anyone has any suggestions for how i can fix this i would be very grateful.

    Thanks

    Andy

  2. #2
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: c# build error

    ah.

    State. If your making some code, you often want to save the state of an object. This is done by serializing the object, in this case to Binary.

    When you do this, a type descriptor gets saved.

    In this case it sounds like you've changed that class slightly, but not the version.

    So whats happening is a class that has the same long name (ie type, assembly, version) but is of a different structure, has been serialized and is now been de-serialized to a different structure of the same long name.

    this is causing the designer to have a world of issues.
    throw new ArgumentException (String, String, Exception)

  3. #3
    Senior Member kasavien's Avatar
    Join Date
    Aug 2005
    Location
    St. Albans
    Posts
    1,829
    Thanks
    145
    Thanked
    104 times in 49 posts

    Re: c# build error

    Thanks for your answer is, is there any way to narrow down the area of code that's causing the issue, or is it not a code issue and i need to be looking somewhere else?

    Thanks

    Andy

  4. #4
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: c# build error

    absolutely.

    you've got a DLL thats been used in the project for a 'usercontrol' that has a reference to Eden.Node[].

    re-compile that DLL, so it references the changed version of Eden.Node[]. Close all designer tabs, clean + rebuild the project with the GUI. Open designer.
    throw new ArgumentException (String, String, Exception)

  5. #5
    Senior Member kasavien's Avatar
    Join Date
    Aug 2005
    Location
    St. Albans
    Posts
    1,829
    Thanks
    145
    Thanked
    104 times in 49 posts

    Re: c# build error

    Ah that kind of works, if i close all tabs clean the solution, then restart visual studio i can open the designer but when i make any changes to the user control the error comes back so does that mean that there are errors in the code too?

  6. #6
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: c# build error

    okay, do you have something like this

    solution foo
    ---+project GUIControls
    --- has the usercontrol .cs files
    ---+project BuisnessObjects
    --- has the Eden.Node class defined.

    what happens is the designer has to hold a copy of the code in memory, when its serialazing/deserializing.

    So everytime you change the Node class, you have to update the usercontrol.

    If you don't have the designer open when making code changes, it shouldn't give you a problem. Make sure you have all the VS service packs installed.
    throw new ArgumentException (String, String, Exception)

  7. #7
    Senior Member kasavien's Avatar
    Join Date
    Aug 2005
    Location
    St. Albans
    Posts
    1,829
    Thanks
    145
    Thanked
    104 times in 49 posts

    Re: c# build error

    All the Gui files and class files are all just part of the same project which is under the solution. Could this be the reason i'm getting these errors but if not should i separate the files into separate projects anyway?

    Thanks again for all your help, it's very much appreciated

    Andy

  8. #8
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: c# build error

    This is a common issue when developing GUI controls. Seperating them out into seperate projects often helps simplify this problem (and isn't bad practice either, business objects been clearly seperated from the UserControls).

    The designer has to load the control. When playing with the control in the designer, it has to have the full code base behind it. Now without seeing the code you've got going on, i can't say exactly, but i can take a damn good guess as to the problem. You've got this Node class, which your using as an array, and saving this into either the resource or .designer (partial class) file to be loaded up each time (the designer will do this for you automatically). If you make a change to Node, whilst keeping the 'FullName' the same (ie the version of the project the Node class is in didn't change) have a look at:
    System.Diagnostics.Debug.WriteLine(typeof (Node).FullName);
    System.Diagnostics.Debug.WriteLine(typeof (string).FullName);
    to see how these work.

    Now when the FullName is the same, but the binary seriazlied data dosen't line up (because the class is different) you will get errors like this, because the usercontrol hasn't been re-compiled, least not in designer memory (as the designer has to take a copy of the compiled usercontrol to allow you to design with it). A top tip for dealign with quirks in the designer, is to close it every time you go off changing anything it depends on (or when your not using it, the designer tab takes a lot of RAM and CPU).

    Another way if you can't set your Node class in stone, look at using an interface, or a class lower down the inherritance higherarchy.
    throw new ArgumentException (String, String, Exception)

  9. #9
    Senior Member kasavien's Avatar
    Join Date
    Aug 2005
    Location
    St. Albans
    Posts
    1,829
    Thanks
    145
    Thanked
    104 times in 49 posts

    Re: c# build error

    Thanks again for your help, i think i've got everything sorted now so development can continue . I had to restructure things a bit to get everything working so hopefully now it's more technically correct too.

    I really need more time to learn things properly, a course would help, but it isn't really practical given the timescales i have. But after uni hopefully i'll have more time to understand and learn how things work.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VS2008 RTM - is this really an RTM build?
    By Spud1 in forum Software
    Replies: 2
    Last Post: 03-12-2007, 08:44 PM
  2. Windows Live Mail Error
    By neonplanet40 in forum Software
    Replies: 2
    Last Post: 26-08-2007, 06:38 PM
  3. Citrix, wcifs32 error
    By RECOiLâ„¢ in forum Software
    Replies: 2
    Last Post: 09-08-2007, 04:13 PM
  4. Unable to make an Order Site Error
    By Gordy in forum SCAN.care@HEXUS
    Replies: 8
    Last Post: 04-07-2006, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •