You need to sign in to do that
Don't have an account?
Invalid conversion from runtime type <class> to <interface>
I am getting a strange error message as above.
I have an interface {say A} which has one method. I have a class {say B} that implements the interface (the method). And I have another class/method that takes interface A as a parameter. And I call that method with an instance of the class B. All compiles ok. But I got the error when running it.
I do not see what can possibly be wrong with my code. If I do not implement the method in A, it fails to compile. If I remove 'implements A' from B, it fails to compile. Also I have another class {C} that implements the interface A, and is used in exact same way and it works fine.
Anyone has seen similar issues?
This was the cause of my problem http://force201.wordpress.com/2012/02/01/add-version-settings-to-the-check-list/.
All Answers
I am seeing the same problem but in a somewhat obscure combination of managed packages and triggers. If you solved your problem please post the solution here as that may help me.
Thanks,
Keith
This was the cause of my problem http://force201.wordpress.com/2012/02/01/add-version-settings-to-the-check-list/.
Yes, it's always a good idea to develop against the latest version. Apex changes a fair bit with each version, so it's always best to make sure the full feature list is available to you.
If you look at the list of reserved keywords:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_reserved_words.htm
You'll see that there quite a few to come. With the documentation referring to the current version of Apex, that's what you should be developing against. Whenever a new version comes out for my dev instance, the first thing I do is change the version of all of my classes/triggers/etc.
To be clear here, the version issue was not with the "Salesforce.com API" where code locked to one version will continue to work against future versions of the platform. But rather that some source code that depended on a managed package broke when the managed package was upgraded which is a failure of the aimed for backward compatibility of managed packages.