Question

This is a problem I have never seen before. Whenever I run a certain command in my application, I am getting the error:

Could not load file or assembly 'CADB.Data'. The system could not find the file specified.

When I run the command in the debugger, I do not get this error. The system completes the process successfully. It is only when I am running the built .exe. The .exe is in my debug folder with all of the necessary DLLs (Copy Local = True) including the problem DLL (CADB.Data).

When the system runs this command, it is under impersonation. I put the Debug folder (containing .exe and DLLs) into a folder the impersonated user has full access to. I checked access in the Security tab of file properties, and the user has full access to the folder AND CADB.Data.dll. Still, I get the error message above. When I run the program through any other folder that the impersonated user does not have access to, I get a slightly different error: Could not load file or assembly 'CADB.Data'. Access is denied.

Running the application through the debugger on another workstation throws the error as well. The error occurs at the declaration of the method GetClaimGuidList which is a member of CADB.Data (below).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CADB.Data;

namespace CADB.BusinessServices
{
public class ClaimHelper
{
    static public List<Entities.Claim> GetClaimGuidList(int caseId, bool includeNotices)
    {
        DataTable dt = ClaimCmd.GetClaimGuids(caseId, includeNotices);
        return Utilities.MapDataTableToList<Entities.Claim>(dt);
    }
}
}

Other things tried:

  • Setting DLL as read/write. It was read-only because the file was originally being edited by VSO and thus had a read-only mark.
  • Running process monitor to look for an access denied message. I don't find such a message anywhere in the monitor.
  • Removing the DLL and adding it again from the project (my solution has multiple projects).
  • Cleaning the entire solution, re-building and re-running the EXE
  • Deleting the bin folder of every project in the solution, re-building and re-trying

Can anyone help? Any ideas would be greatly appreciated. Thanks.

Was it helpful?

Solution

For some reason, the impersonated user did not have access to the application files created in the bin folder. I went to the Security properties of the folder and added that user to the folder with full access rights. This allowed us to bypass the error. Why the user was not able to access the CADB.Data DLL is still a mystery. In any case, the issue was not present in the published ClickOnce application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top