Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while compiling a library in C#

Tags:

c#-4.0

I am trying to compile a class(sqlAccess) declared as public with few methods related to database connection in it. I am getting the following error ...

Error   1   Friend access was granted to 'SqlAccess, PublicKey=00c8', but the      output assembly is named 'SQLAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'SqlAccess, PublicKey=00c8' or changing the output assembly name to match.    c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll  SQLAccess

What could be the reason? is there already a method of that name? I am new to programming so am unable to understand this clearly. Thank you.

like image 406
Krishna Chaitanya M Avatar asked Dec 13 '22 14:12

Krishna Chaitanya M


2 Answers

This worked for me: Open the Properties|Signing Tab. Ensure that you have "Sign the Assembly" checked and the strong name key file referenced. Save and compile the Project/Solution. (cited from MSDN)

like image 116
Omidoo Avatar answered Feb 11 '23 15:02

Omidoo


.NET seems to get grumpy if you give your assembly/project a name that isn't unique. In your case, SqlAccess must already exist in .NET or a referenced assembly.

The fix is to rename your assembly.

Similar issue: Weird error in C#

like image 32
Dunc Avatar answered Feb 11 '23 15:02

Dunc