Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have made a custom rule and implemented it with other FxCop Rules, however, it says for this particular rule it cannot load the class c1.

Earlier I thought it is because I had not given proper namespace of the rules.xml file, but inspite of having corrected that. It still cannot load my rule and is giving an exception. I am sharing my code below:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.FxCop;
//using Microsoft.cci;
using Microsoft.FxCop.Sdk;

namespace CustomFxCopRule
{

    public class classc1 : BaseIntrospectionRule
    {
        int flag = 0;
        public classc1()
            : base("classc1", "CustomFxCopRule.Rules", typeof(classc1).Assembly)
        { }

        public override void BeforeAnalysis()
        {
            // Do once-per-thread initialization.
        }
        public override void AfterAnalysis()
        {
            // Do once-per-thread cleanup. Rarely needed.
        }
        public override ProblemCollection Check(Member member)
        {
            //Logic here
           return Problems;
        }


    }
}


I have checked the syntax but cannot find why my rule cannot be loaded and is giving an exception.

Thanks in advance for all the help.
Posted
Comments
Mathi Mani 26-May-15 18:07pm    
Is this the complete code? Which line throws the exception? Shed some light.
Shivangi_K 27-May-15 1:42am    
It cannot load the class itself, so there is no execution in the first place. I read about it and realized I had given incorrect namespace in the CustomFxCopRule.Rules place, However, even after correcting the code, I am getting this error. WHen I checked the bin for this project, it is not getting modified... :(
Shivangi_K 27-May-15 1:48am    
In what conditions can a file not be modified even if you are saving the changes? How do I troubleshoot this?
Mathi Mani 27-May-15 1:54am    
Is this the main class or some other class utilizes this class (by creating object of this class). This kind of error happens when one or more of the dependent libraries (DLLs) are not present in the referenced folders. Did you check that?
Shivangi_K 27-May-15 1:58am    
You mean the FxCOP assembly should be there in the folder where I paste my custom rule? It is the only class which contains the rule.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900