none
DLL is inaccessible due to its protection level. AND The type or namespace name 'TFSLoggerDummy' could not be found (are you missing a using directive or an assembly reference?) RRS feed

  • Question

  • Dear All,

    I am facing a weird problem with one of the dll I am trying to use in another project.

    So what I did:

    I create a console application. Wrote very basic code. Now I want to make use of the function created in console application in my coded ui project.

    I created a new coded UI project. From Bin folder of consoles application , release folder I copied the DLL to current project and added reference of console application dll to current Coded UI Project.

    In my coded ui test file (.cs) file. I used the statement "using DLLName;", for some time it does get highlighted as an error with red line. Movement I try to write a line of code it highlight it as an error. Mouse over it show the error "The type or namespace name 'TFSLoggerDummy' could not be found (are you missing a using directive or an assembly reference?)".

    I tried to build the application to get more details on the issue. However the build succeeds. 

     As it showed build succeeds message. I tried another thing I tried to still force the use of DLL. I tried to create an object of the class available in DLL.

    It gave me an error "DLL is inaccessible due to its protection level", when build or highlighted over the statement to create the object.

    I am not sure if I have done a mistake. If not , not sure how I shall remove the error.

    Thank you. 


    Ahetejazahmad Khan.

    Tuesday, October 17, 2017 12:00 PM

Answers

  • TFSLoggerDummy is the name of an assembly and likely the name of the namespace within it. Since you have a using statement in your test code you don't need to include it in the new statement.

    But the error says the protection level is inaccessible. That means the Program class you're trying to create isn't accessible, aka it isn't public. If you're trying to unit test an executable then the executable's Program type isn't going to be accessible by default. Change the accessibility and try again.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Ahetejaz Wednesday, October 18, 2017 7:18 AM
    Tuesday, October 17, 2017 3:59 PM
    Moderator

All replies

  • Hi Ahetejaz,

    I believe you are creating object wrong. Can you please try following:

    TFSLoggerDummy tfsObject = new TFSLoggerDummy();
    tfsObject.Program


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Tuesday, October 17, 2017 2:26 PM
    Moderator
  • TFSLoggerDummy is the name of an assembly and likely the name of the namespace within it. Since you have a using statement in your test code you don't need to include it in the new statement.

    But the error says the protection level is inaccessible. That means the Program class you're trying to create isn't accessible, aka it isn't public. If you're trying to unit test an executable then the executable's Program type isn't going to be accessible by default. Change the accessibility and try again.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Ahetejaz Wednesday, October 18, 2017 7:18 AM
    Tuesday, October 17, 2017 3:59 PM
    Moderator