I am building a website using asp.net core mvc, and for the login i added dependency for enc.dll file, which just encrypt/decrypt user information. I made a Seeder class with enc.dll file, which has a key property and en/decrypt with the key. Then I added it to my service to use dependency injection feature.
services.AddSingleton<ISeeder, Seeder>();
While it works well when i call enc, dec function of seeder class, it does not return any error. Below is the example code.
private readonly ISeeder seed;
public AccountController(ISeeder seed)
{
this.seed = seed;
}
[HttpGet]
public IActionResult test()
{
string s = seed.Enc("testEncode");
return Json(s);
}
So it works when i return string s that is created by seed instance.
but it is not working when i try to return a view without using seed instance and throwing an error, where Enc is the dll library i am using.
InvalidOperationException: Cannot find compilation library location for package 'Enc'
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List<string> assemblies)
And below is my Seeder code.
private Enc enc;
private readonly EncKey key;
public Seeder(IOptions<EncKey> options)
{
enc = new Enc();
key = options.Value;
}
public string Dec(string toDec)
{
return enc.Dec(toDec, key.EncryptKey);
}
public string Enc(string toEnc)
{
return enc.Enc(toEnc, key.EncryptKey);
}
Could anyone help? I am working on .net core 2.0 environment