+ Start a Discussion
AnnaTAnnaT 

[ERROR] Dependent class is invalid and needs recompilation

How can I solve this error?

 

<snapshot>

https://c.na10.content.force.com/servlet/servlet.FileDownload?file=0F0F0000000rI8J

 

The following is a related link I posted before.

http://boards.developerforce.com/t5/Visualforce-Development/After-clicking-save-button/td-p/290213

 

I tried all advices, but error didn't disappear.

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

 

Here is your test class
@isTest
private class SaveControllerTest {

static testMethod void SaveController() {
        
		
 List<CR_CO__c> listCrco = new List<CR_CO__c>();                
                ApexPages.StandardSetController SController = new ApexPages.StandardSetController(listCrco); 
SaveController savecon = new SaveController(SController); 
    }
}

 

 

All Answers

Shashikant SharmaShashikant Sharma

The reason for this error is that any class which dependent class refers to has changed the signature of any method or method got removed from the refered class. Please recompile the dependent class to figure out the result.

AnnaTAnnaT

Thank you for helping me everytime.

 

I found that if I remove the following code, error doesn't occur.

 

public SaveController(ApexPages.StandardSetController controller) {

} 

 I think I should do something before using "ApexPages.StandardSetController".

 

 

Thanks,

Anna

Shashikant SharmaShashikant Sharma

Is this constructor in dependent class or in refered class? Can you please provide both the classes

AnnaTAnnaT

I'm sorry but I don't know well about programing and I don't know the class is dependent class or in refered class...

 

So, I update all of my code. 

 

 

CLASS: SaveController.cls

 

public with sharing class SaveController {

public SaveController(ApexPages.StandardSetController controller) {

} 
     public PageReference save() {
         PageReference nextPageURL = new PageReference('/apex/Statuslist');
        
        return nextPageURL;                         
     } 
}

 

 

TEST CLASS: SaveControllerTest.cls

 

@isTest
private class SaveControllerTest {

    static testMethod void SaveController() {
        SaveController savecon = new SaveController();
    }
}

 When I try this test, the error appears.

 

 

Thank you very much for your help.

Anna

Shashikant SharmaShashikant Sharma

Here is your problem

 

@isTest
private class SaveControllerTest {

    static testMethod void SaveController() {
        SaveController savecon = new SaveController();
    }
}

 You don't have constructor like this which do not have parameter, earlier when you must have had this when you created test class.

 

 

 

now there are two options for

1) change your class

 

 

public with sharing class SaveController {

public SaveController(ApexPages.StandardSetController controller) {

} 

//Add another constructor , you can remove above if you don' need this means if the VFP that used it do not have standard controller
public SaveController() {

} 
     public PageReference save() {
         PageReference nextPageURL = new PageReference('/apex/Statuslist');
        
        return nextPageURL;                         
     } 
}

 

 

 

 

Way :2 Change test class and pass standard controller when you create instance of your class in test method.

 

AnnaTAnnaT

Thank you for your prompt reply.

Your reply is much faster than salesfoce support desk !!

 

I noticed that my test code is wrong.

My VFP has standard controller, so as your advice, my class is this.

 

 

public with sharing class SaveController {


public SaveController(ApexPages.StandardSetController controller) {

} 
 

     public PageReference save() {
         PageReference nextPageURL = new PageReference('/apex/Statuslist');
        
        return nextPageURL;                         
     } 
}

 

 

Test code is a problem...

How can I write test code when handling standard controller? 

I use parameter  "SaveController(ApexPages.StandardSetController controller)" in SaveController class,

so I think I need to use parameter in test code, too.

But test doesn't go without any error...

@isTest
private class SaveControllerTest {

static testMethod void SaveController() {
        
		CR_CO__c crco = new CR_CO__c(); 

ApexPages.StandardSetController SController = new ApexPages.StandardSetController(crco); 
SaveController savecon = new SaveController(SController); 
    }
}

 

 

 

Shashikant SharmaShashikant Sharma

 

Here is your test class
@isTest
private class SaveControllerTest {

static testMethod void SaveController() {
        
		
 List<CR_CO__c> listCrco = new List<CR_CO__c>();                
                ApexPages.StandardSetController SController = new ApexPages.StandardSetController(listCrco); 
SaveController savecon = new SaveController(SController); 
    }
}

 

 

This was selected as the best answer
AnnaTAnnaT

I finally solve this problem !!

Thank you very much for your help!!!!!!!!!

Shashikant SharmaShashikant Sharma

Your welcome :)