views:

171

answers:

2

this error is driving me nuts:

Unit Test Adapter threw exception: Type 'com.imagehawk.ZDRCreator.Config.ZDRCreatorConfigException' in assembly 'ZDRCreator, Version=1.0.5.1, Culture=neutral, PublicKeyToken=null' is not marked as serializable..

it's an exception, the only places it's used is like this throw new ZDRCreatorConfigException(bla); and then in catch blocks of course.

just started happening ... can't figure out what i changed. please help

here's the code for the exception, though I doubt it helps.

public class ZDRCreatorConfigException : Exception
    {
        public ZDRCreatorConfigException(string msg) : base(msg)
        {
        }

        public ZDRCreatorConfigException() : base()
        {
        }
    }

UPDATE: I figured it out, and it wasn't Microsofts fault after all; although the swearing I gave them I'm sure there's plenty of other things they deserve it for. I had made a code change that was causing that exception to be thrown and never handled. Not sure why it mentioned serializable unless it's because not all the constructors are implemented here. Btw, I was finally able to figure out where to put the break point to find the problem. Thanks!

+1  A: 

You probably just removed the Serializable attribute:

    [Serializable]
    public class ZDRCreatorConfigException : Exception 
    { 
        public ZDRCreatorConfigException(string msg) : base(msg) 
        { 
        } 

        public ZDRCreatorConfigException() : base() 
        { 
        } 
    } 
SwDevMan81
adding [Serializable] doesn't help. And I diff using cvs I know it wasn't there before either. There's no changes to the class.
cchampion
Did you recently change some Exception settings in the project. So if you go to Debug -> Exceptions -> Common Language Runtime Exceptions -> System.Runtime.Serialization (SerializationException), was this recently changed?
SwDevMan81
Could you post the code of the Unit Test that fails?
SwDevMan81
+1  A: 

I'm not sure if you have access to the source code, but have you tried adding a Serializable attribute as it suggests?

[Serializable]
public class ZDRCreatorConfigException : Exception
{
    ...
}

If you make this change it will help you because you will get the stacktrace of where the original error occurred instead of the stacktrace of where serializing the exception failed. You should make this change if possible and then update your question with the new error message and stacktrace.

Also, you should try to work out why that exception is being thrown, as I guess that it is not meant to happen. If you test in debug mode you can set up Visual Studio to break automatically when that exception is thrown so that you can see what happens.

Mark Byers
adding [Serializable] doesn't help. And I diff using cvs I know it wasn't there before either. There's no changes to the class.I set breakpoints in all the methods in the test file (there's only one), including the initialization method and ctor, and it doesn't hit any of them. it stops before it hits them.
cchampion
@cchampion: What do you mean by adding [Serializable] doesn't help? It should cause the error to change to another error. Do you get exactly the same error, or do you get a new error? If you get a new error then what is it? If you get the same error, are you sure that it's *exactly* the same error, the same message, the stack trace, everything? Are you 100% sure that you have recompiled the code correctly and that it is picking up the new .DLL from the correct location?
Mark Byers