drhanlau
drhanlau

Reputation: 2527

Weird error in C#

I have the following code,

TextWriter writer = new StreamWriter(@"c:\temp\abc.txt")

but it is raising this in while compile

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

Anyone has an idea why?

Upvotes: 1

Views: 2724

Answers (2)

Tim Lloyd
Tim Lloyd

Reputation: 38444

Shot in the dark...

Have you called your project "System", or do you have "System" in your namepsace? If you have .Net will get terribly confused as there is already something called System.dll. Call your project something else, so the output dll is named differently.

Upvotes: 9

Francesco
Francesco

Reputation: 10830

Do you have different versions of same DLLs? In the past I got a similar exception when I installed two versions of Crystal Report and used its APIs in my code.

Upvotes: 0

Related Questions